1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-04 05:43:47 +00:00

Add boutNumber to upcomgingMatches

This commit is contained in:
2015-03-12 15:18:06 -04:00
parent dc9639cf1c
commit e8dd332bbc
4 changed files with 24 additions and 15 deletions

View File

@@ -1,15 +1,8 @@
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)
def matchesByRound(round, matches)
@matches = matches.select {|m| m.round == round}
return @matches
end
@@ -18,7 +11,21 @@ class Bout
@matches.each_with_index do |m, i|
bout = m.round * 1000 + i
m.boutNumber = bout
m.save
end
return @matches
end
def assignBouts(matches)
@round = 1
until matchesByRound(@round, matches).blank? do
@matches = matchesByRound(@round, matches)
giveBout(@matches)
@round += 1
end
return matches
end
end