1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-03 13:30:02 +00:00

Put finals in same round

This commit is contained in:
2015-12-07 15:24:42 +00:00
parent 5a09c60a41
commit d28e95ed31
4 changed files with 28 additions and 11 deletions

View File

@@ -21,9 +21,19 @@ module GeneratesTournamentMatches
end
def generateMatches
moveFinalsMatchesToLastRound
assignBouts
assignLoserNames
assignFirstMatchesToMats
end
def moveFinalsMatchesToLastRound
finalsRound = self.totalRounds
finalsMatches = self.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"}
finalsMatches. each do |m|
m.round = finalsRound
m.save
end
end
end

View File

@@ -50,6 +50,6 @@ class Tournament < ActiveRecord::Base
end
def totalRounds
self.matches.sort_by{|m| m.bout_number}.last.round
self.matches.sort_by{|m| m.round}.last.round
end
end