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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user