mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-05 14:17:20 +00:00
Reducing queries on up_matches and brackets
This commit is contained in:
@@ -6,7 +6,7 @@ class StaticPagesController < ApplicationController
|
|||||||
end
|
end
|
||||||
def up_matches
|
def up_matches
|
||||||
if params[:tournament]
|
if params[:tournament]
|
||||||
@tournament = Tournament.find(params[:tournament])
|
@tournament = Tournament.where(:id => params[:tournament]).includes(:matches).first
|
||||||
end
|
end
|
||||||
if @tournament
|
if @tournament
|
||||||
@matches = @tournament.matches.where(mat_id: nil).order('bout_number ASC').limit(10).includes(:wrestlers)
|
@matches = @tournament.matches.where(mat_id: nil).order('bout_number ASC').limit(10).includes(:wrestlers)
|
||||||
@@ -39,8 +39,8 @@ class StaticPagesController < ApplicationController
|
|||||||
|
|
||||||
def brackets
|
def brackets
|
||||||
if params[:weight]
|
if params[:weight]
|
||||||
@weight = Weight.find(params[:weight]).includes(:matches,:wrestlers)
|
@weight = Weight.where(:id => params[:weight]).includes(:matches,:wrestlers,:tournament).first
|
||||||
@tournament = Tournament.find(@weight.tournament_id)
|
@tournament = @weight.tournament
|
||||||
@matches = @weight.matches
|
@matches = @weight.matches
|
||||||
@wrestlers = @weight.wrestlers.includes(:school)
|
@wrestlers = @weight.wrestlers.includes(:school)
|
||||||
if @matches.empty? or @wrestlers.empty?
|
if @matches.empty? or @wrestlers.empty?
|
||||||
|
|||||||
Reference in New Issue
Block a user