1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-11 16:01:56 +00:00

Generated bouts and rounds. Need to fix rounds for odd numbered pools.

This commit is contained in:
2015-02-03 10:41:49 -05:00
parent 7ea80b2997
commit 0244d15a8b
8 changed files with 62 additions and 24 deletions

View File

@@ -1,3 +1,24 @@
class Bout
def assignBouts(tournament_id)
@round = 1
until matchesByRound(@round, tournament_id).blank? do
@matches = matchesByRound(@round, tournament_id)
giveBout(@matches)
@round += 1
end
end
def matchesByRound(round, tournament_id)
@matches = Match.where(tournament_id: tournament_id, round: round)
return @matches
end
def giveBout(matches)
@matches = matches.sort_by{|x|[x.weight_max]}
@matches.each_with_index do |m, i|
bout = m.round * 100 + i
m.boutNumber = bout
m.save
end
end
end