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

Fixed an infinite loop in pool_order when calculating pool order for a single pool bracket

This commit is contained in:
2019-01-30 13:34:27 +00:00
parent f43cd316f6
commit 71c8a0dc99
2 changed files with 6 additions and 2 deletions

View File

@@ -36,6 +36,10 @@ class Wrestler < ActiveRecord::Base
def total_points_deducted def total_points_deducted
CalculateWrestlerTeamScore.new(self).deductedPoints CalculateWrestlerTeamScore.new(self).deductedPoints
end end
def total_pool_points_for_pool_order
CalculateWrestlerTeamScore.new(self).poolPoints + CalculateWrestlerTeamScore.new(self).bonusWinPoints
end
def next_match def next_match
unfinished_matches.first unfinished_matches.first

View File

@@ -135,10 +135,10 @@ class PoolOrder
def teamPoints def teamPoints
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.team_points_earned pointsArray << w.total_pool_points_for_pool_order
end end
mostPoints = pointsArray.max 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) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)