mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Fixed an infinite loop in pool_order when calculating pool order for a single pool bracket
This commit is contained in:
@@ -37,6 +37,10 @@ class Wrestler < ActiveRecord::Base
|
||||
CalculateWrestlerTeamScore.new(self).deductedPoints
|
||||
end
|
||||
|
||||
def total_pool_points_for_pool_order
|
||||
CalculateWrestlerTeamScore.new(self).poolPoints + CalculateWrestlerTeamScore.new(self).bonusWinPoints
|
||||
end
|
||||
|
||||
def next_match
|
||||
unfinished_matches.first
|
||||
end
|
||||
|
||||
@@ -135,10 +135,10 @@ class PoolOrder
|
||||
def teamPoints
|
||||
pointsArray = []
|
||||
wrestlersWithSamePoints.each do |w|
|
||||
pointsArray << w.team_points_earned
|
||||
pointsArray << w.total_pool_points_for_pool_order
|
||||
end
|
||||
mostPoints = pointsArray.max
|
||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.team_points_earned == mostPoints}
|
||||
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.total_pool_points_for_pool_order == mostPoints}
|
||||
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
|
||||
wrestlersWithLeastDeductedPoints.each do |wr|
|
||||
addPoints(wr)
|
||||
|
||||
Reference in New Issue
Block a user