1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-09 23:44:52 +00:00

Reducing queries for upcoming matches

This commit is contained in:
2015-03-16 08:06:08 -04:00
parent e8dd332bbc
commit 05c340eb94
4 changed files with 23 additions and 35 deletions

View File

@@ -20,7 +20,7 @@ class Weight < ActiveRecord::Base
end
def pools
@wrestlers = Wrestler.where(weight_id: self.id)
@wrestlers = self.wrestlers
if @wrestlers.size <= 6
self.pools = 1
elsif (@wrestlers.size > 6) && (@wrestlers.size <= 10)
@@ -49,17 +49,17 @@ class Weight < ActiveRecord::Base
end
def generateMatchups(matches)
@wrestlers = Wrestler.where(weight_id: self.id)
@wrestlers = self.wrestlers
#@wrestlers.sort_by{|w| [w.original_seed]}
if self.pools == 1
@pool = Pool.new
@matches = @pool.onePool(@wrestlers,self.id,self.tournament_id,matches)
@matches = @pool.onePool(@wrestlers,self,self.tournament_id,matches)
elsif self.pools == 2
@pool = Pool.new
@matches = @pool.twoPools(@wrestlers,self.id,self.tournament_id,matches)
@matches = @pool.twoPools(@wrestlers,self,self.tournament_id,matches)
elsif self.pools == 4
@pool = Pool.new
@matches = @pool.fourPools(@wrestlers,self.id,self.tournament_id,matches)
@matches = @pool.fourPools(@wrestlers,self,self.tournament_id,matches)
end
return @matches
end