mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Fixed a couple slow queries
This commit is contained in:
@@ -15,6 +15,10 @@ class ApiController < ApplicationController
|
||||
|
||||
def tournament
|
||||
@tournament = Tournament.where(:id => params[:tournament]).includes(:schools,:weights,:mats,:matches,:user,:wrestlers).first
|
||||
@schools = @tournament.schools.includes(:wrestlers)
|
||||
@weights = @tournament.weights.includes(:wrestlers)
|
||||
@matches = @tournament.matches.includes(:wrestlers,:schools)
|
||||
@mats = @tournament.mats.includes(:matches)
|
||||
end
|
||||
|
||||
def newTournament
|
||||
|
||||
@@ -12,8 +12,7 @@ class SchoolsController < ApplicationController
|
||||
# GET /schools/1.json
|
||||
def show
|
||||
session.delete(:return_path)
|
||||
@wrestlers = @school.wrestlers.includes(:deductedPoints,:matches,:weight)
|
||||
@tournament = @school.tournament
|
||||
@wrestlers = @school.wrestlers.includes(:deductedPoints,:matches,:weight,:school)
|
||||
end
|
||||
|
||||
# GET /schools/new
|
||||
|
||||
@@ -174,12 +174,14 @@ class TournamentsController < ApplicationController
|
||||
def all_brackets
|
||||
@schools = @tournament.schools
|
||||
@schools = @schools.sort_by{|s| s.page_score_string}.reverse!
|
||||
@matches = @tournament.matches.includes(:wrestlers,:schools)
|
||||
@weights = @tournament.weights.includes(:matches,:wrestlers)
|
||||
end
|
||||
|
||||
def bracket
|
||||
if params[:weight]
|
||||
@weight = Weight.where(:id => params[:weight]).includes(:matches,:wrestlers).first
|
||||
@matches = @weight.matches
|
||||
@matches = @weight.matches.includes(:schools,:wrestlers)
|
||||
@wrestlers = @weight.wrestlers.includes(:school)
|
||||
if @tournament.tournament_type == "Pool to bracket"
|
||||
@pools = @weight.pool_rounds(@matches)
|
||||
|
||||
Reference in New Issue
Block a user