1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-12 00:09:32 +00:00

Refactored names of methods and some db column

This commit is contained in:
2018-11-13 14:14:48 +00:00
parent 93be525832
commit d67a8f2b42
44 changed files with 350 additions and 350 deletions

View File

@@ -9,7 +9,7 @@ class ApiController < ApplicationController
if params[:search] if params[:search]
@tournaments = Tournament.search(params[:search]).order("created_at DESC") @tournaments = Tournament.search(params[:search]).order("created_at DESC")
else else
@tournaments = Tournament.all.sort_by{|t| t.daysUntil}.first(20) @tournaments = Tournament.all.sort_by{|t| t.days_until_start}.first(20)
end end
end end

View File

@@ -6,7 +6,7 @@ class MatsController < ApplicationController
# GET /mats/1 # GET /mats/1
# GET /mats/1.json # GET /mats/1.json
def show def show
@match = @mat.unfinishedMatches.first @match = @mat.unfinished_matches.first
if @match if @match
@w1 = @match.wrestler1 @w1 = @match.wrestler1
@w2 = @match.wrestler2 @w2 = @match.wrestler2

View File

@@ -4,7 +4,7 @@ class StaticPagesController < ApplicationController
tournaments_created = current_user.tournaments tournaments_created = current_user.tournaments
tournaments_delegated = current_user.delegated_tournaments tournaments_delegated = current_user.delegated_tournaments
all_tournaments = tournaments_created + tournaments_delegated all_tournaments = tournaments_created + tournaments_delegated
@tournaments = all_tournaments.sort_by{|t| t.daysUntil} @tournaments = all_tournaments.sort_by{|t| t.days_until_start}
@schools = current_user.delegated_schools @schools = current_user.delegated_schools
end end

View File

@@ -12,7 +12,7 @@ class TournamentsController < ApplicationController
def swap def swap
@wrestler = Wrestler.find(params[:wrestler][:originalId]) @wrestler = Wrestler.find(params[:wrestler][:originalId])
respond_to do |format| respond_to do |format|
if SwapWrestlers.new.swapWrestlers(params[:wrestler][:originalId], params[:wrestler][:swapId]) if SwapWrestlers.new.swap_wrestlers_bracket_lines(params[:wrestler][:originalId], params[:wrestler][:swapId])
format.html { redirect_to "/tournaments/#{@wrestler.tournament.id}/brackets/#{@wrestler.weight.id}", notice: 'Wrestler was successfully swaped.' } format.html { redirect_to "/tournaments/#{@wrestler.tournament.id}/brackets/#{@wrestler.weight.id}", notice: 'Wrestler was successfully swaped.' }
format.json { render action: 'show', status: :created, location: @wrestler } format.json { render action: 'show', status: :created, location: @wrestler }
end end
@@ -143,7 +143,7 @@ class TournamentsController < ApplicationController
def create_custom_weights def create_custom_weights
@custom = params[:customValue].to_s @custom = params[:customValue].to_s
@tournament.createCustomWeights(@custom) @tournament.create_pre_defined_weights(@custom)
redirect_to "/tournaments/#{@tournament.id}" redirect_to "/tournaments/#{@tournament.id}"
end end
@@ -157,7 +157,7 @@ class TournamentsController < ApplicationController
@weight = Weight.where(:id => params[:weight]).includes(:matches,:wrestlers).first @weight = Weight.where(:id => params[:weight]).includes(:matches,:wrestlers).first
@matches = @weight.matches @matches = @weight.matches
@wrestlers = @weight.wrestlers.includes(:school) @wrestlers = @weight.wrestlers.includes(:school)
@pools = @weight.poolRounds(@matches) @pools = @weight.pool_rounds(@matches)
@bracketType = @weight.pool_bracket_type @bracketType = @weight.pool_bracket_type
end end
end end
@@ -172,7 +172,7 @@ class TournamentsController < ApplicationController
def team_scores def team_scores
@schools = @tournament.schools @schools = @tournament.schools
@schools = @schools.sort_by{|s| s.pageScore}.reverse! @schools = @schools.sort_by{|s| s.page_score_string}.reverse!
end end
@@ -190,7 +190,7 @@ class TournamentsController < ApplicationController
if params[:search] if params[:search]
@tournaments = Tournament.search(params[:search]).order("created_at DESC") @tournaments = Tournament.search(params[:search]).order("created_at DESC")
else else
@tournaments = Tournament.all.sort_by{|t| t.daysUntil}.first(20) @tournaments = Tournament.all.sort_by{|t| t.days_until_start}.first(20)
end end
end end
@@ -276,7 +276,7 @@ class TournamentsController < ApplicationController
end end
def check_tournament_errors def check_tournament_errors
if @tournament.tournamentMatchGenerationError != nil if @tournament.match_generation_error != nil
respond_to do |format| respond_to do |format|
format.html { redirect_to "/tournaments/#{@tournament.id}/error" } format.html { redirect_to "/tournaments/#{@tournament.id}/error" }
end end

View File

@@ -6,21 +6,21 @@ class Mat < ActiveRecord::Base
before_destroy do before_destroy do
if tournament.matches.size > 0 if tournament.matches.size > 0
tournament.resetMats tournament.reset_mats
matsToAssign = tournament.mats.select{|m| m.id != self.id} matsToAssign = tournament.mats.select{|m| m.id != self.id}
tournament.assignMats(matsToAssign) tournament.assign_mats(matsToAssign)
end end
end end
after_create do after_create do
if tournament.matches.size > 0 if tournament.matches.size > 0
tournament.resetMats tournament.reset_mats
matsToAssign = tournament.mats matsToAssign = tournament.mats
tournament.assignMats(matsToAssign) tournament.assign_mats(matsToAssign)
end end
end end
def assignNextMatch def assign_next_match
t_matches = tournament.matches.select{|m| m.mat_id == nil && m.finished != 1 && m.bout_number != nil} t_matches = tournament.matches.select{|m| m.mat_id == nil && m.finished != 1 && m.bout_number != nil}
if t_matches.size > 0 if t_matches.size > 0
match = t_matches.sort_by{|m| m.bout_number}.first match = t_matches.sort_by{|m| m.bout_number}.first
@@ -29,7 +29,7 @@ class Mat < ActiveRecord::Base
end end
end end
def unfinishedMatches def unfinished_matches
matches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number} matches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number}
end end

View File

@@ -13,19 +13,19 @@ class Match < ActiveRecord::Base
wrestler2.touch wrestler2.touch
end end
if self.mat if self.mat
self.mat.assignNextMatch self.mat.assign_next_match
end end
advance_wrestlers advance_wrestlers
calcSchoolPoints calculate_school_points
end end
end end
WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"] WIN_TYPES = ["Decision", "Major", "Tech Fall", "Pin", "Forfeit", "Injury Default", "Default", "DQ"]
def calcSchoolPoints def calculate_school_points
if self.w1 && self.w2 if self.w1 && self.w2
wrestler1.school.calcScore wrestler1.school.calculate_score
wrestler2.school.calcScore wrestler2.school.calculate_score
end end
end end
@@ -38,12 +38,12 @@ class Match < ActiveRecord::Base
end end
end end
def pinTime def pin_time_in_seconds
if self.win_type == "Pin" if self.win_type == "Pin"
time = self.score.delete("") time = self.score.delete("")
minInSeconds = time.partition(':').first.to_i * 60 minutes_in_seconds = time.partition(':').first.to_i * 60
sec = time.partition(':').last.to_i sec = time.partition(':').last.to_i
return minInSeconds + sec return minutes_in_seconds + sec
else else
nil nil
end end
@@ -57,7 +57,7 @@ class Match < ActiveRecord::Base
end end
def bracketScore def bracket_score_string
if self.finished != 1 if self.finished != 1
return "" return ""
end end
@@ -99,7 +99,7 @@ class Match < ActiveRecord::Base
self.loser2_name self.loser2_name
end end
end end
def winnerName def winner_name
if self.finished != 1 if self.finished != 1
return "" return ""
end end
@@ -114,17 +114,17 @@ class Match < ActiveRecord::Base
self.weight.max self.weight.max
end end
def replaceLoserNameWithWrestler(w,loserName) def replace_loser_name_with_wrestler(w,loser_name)
if self.loser1_name == loserName if self.loser1_name == loser_name
self.w1 = w.id self.w1 = w.id
self.save self.save
end end
if self.loser2_name == loserName if self.loser2_name == loser_name
self.w2 = w.id self.w2 = w.id
self.save self.save
end end
end end
def poolNumber def pool_number
if self.w1? if self.w1?
wrestler1.pool wrestler1.pool
end end

View File

@@ -7,11 +7,11 @@ class School < ActiveRecord::Base
validates :name, presence: true validates :name, presence: true
before_destroy do before_destroy do
self.tournament.destroyAllMatches self.tournament.destroy_all_matches
end end
#calculate score here #calculate score here
def pageScore def page_score_string
if self.score == nil if self.score == nil
return 0.0 return 0.0
else else
@@ -19,26 +19,26 @@ class School < ActiveRecord::Base
end end
end end
def calcScore def calculate_score
newScore = totalWrestlerPoints - totalDeductedPoints newScore = total_points_scored_by_wrestlers - total_points_deducted
self.score = newScore self.score = newScore
self.save self.save
end end
if Rails.env.production? if Rails.env.production?
handle_asynchronously :calcScore handle_asynchronously :calculate_score
end end
def totalWrestlerPoints def total_points_scored_by_wrestlers
points = 0 points = 0
self.wrestlers.each do |w| self.wrestlers.each do |w|
if w.extra != true if w.extra != true
points = points + w.totalTeamPoints points = points + w.total_team_points
end end
end end
points points
end end
def totalDeductedPoints def total_points_deducted
points = 0 points = 0
deductedPoints.each do |d| deductedPoints.each do |d|
points = points + d.points points = points + d.points

View File

@@ -15,9 +15,9 @@ class Teampointadjust < ActiveRecord::Base
if self.wrestler_id != nil if self.wrestler_id != nil
#In case this affects pool order #In case this affects pool order
AdvanceWrestler.new(self.wrestler).advance AdvanceWrestler.new(self.wrestler).advance
self.wrestler.school.calcScore self.wrestler.school.calculate_score
elsif self.school_id != nil elsif self.school_id != nil
self.school.calcScore self.school.calculate_score
end end
end end

View File

@@ -14,7 +14,7 @@ class Tournament < ActiveRecord::Base
where("date LIKE ? or name LIKE ?", "%#{search}%", "%#{search}%") where("date LIKE ? or name LIKE ?", "%#{search}%", "%#{search}%")
end end
def daysUntil def days_until_start
time = (Date.today - self.date).to_i time = (Date.today - self.date).to_i
if time < 0 if time < 0
time = time * -1 time = time * -1
@@ -26,7 +26,7 @@ class Tournament < ActiveRecord::Base
["Pool to bracket"] ["Pool to bracket"]
end end
def createCustomWeights(value) def create_pre_defined_weights(value)
weights.destroy_all weights.destroy_all
if value == 'hs' if value == 'hs'
Weight::HS_WEIGHT_CLASSES.each do |w| Weight::HS_WEIGHT_CLASSES.each do |w|
@@ -37,32 +37,32 @@ class Tournament < ActiveRecord::Base
end end
end end
def destroyAllMatches def destroy_all_matches
matches.destroy_all matches.destroy_all
end end
def matchesByRound(round) def matches_by_round(round)
matches.joins(:weight).where(round: round).order("weights.max") matches.joins(:weight).where(round: round).order("weights.max")
end end
def totalRounds def total_rounds
self.matches.sort_by{|m| m.round}.last.round self.matches.sort_by{|m| m.round}.last.round
end end
def assignMats(matsToAssign) def assign_mats(mats_to_assign)
if matsToAssign.count > 0 if mats_to_assign.count > 0
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4 until mats_to_assign.sort_by{|m| m.id}.last.matches.count == 4
matsToAssign.sort_by{|m| m.id}.each do |m| mats_to_assign.sort_by{|m| m.id}.each do |m|
m.assignNextMatch m.assign_next_match
end end
end end
end end
end end
def resetMats def reset_mats
matchesToReset = matches.select{|m| m.mat_id != nil} matches_to_reset = matches.select{|m| m.mat_id != nil}
# matchesToReset.update_all( {:mat_id => nil } ) # matches_to_reset.update_all( {:mat_id => nil } )
matchesToReset.each do |m| matches_to_reset.each do |m|
m.mat_id = nil m.mat_id = nil
m.save m.save
end end
@@ -83,7 +83,7 @@ class Tournament < ActiveRecord::Base
point_adjustments point_adjustments
end end
def removeSchoolDelegations def remove_school_delegations
self.schools.each do |s| self.schools.each do |s|
s.delegates.each do |d| s.delegates.each do |d|
d.destroy d.destroy
@@ -91,7 +91,7 @@ class Tournament < ActiveRecord::Base
end end
end end
def poolToBracketWeightsWithTooManyWrestlers def pool_to_bracket_weights_with_too_many_wrestlers
if self.tournament_type == "Pool to bracket" if self.tournament_type == "Pool to bracket"
weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 16} weightsWithTooManyWrestlers = weights.select{|w| w.wrestlers.size > 16}
if weightsWithTooManyWrestlers.size < 1 if weightsWithTooManyWrestlers.size < 1
@@ -104,11 +104,11 @@ class Tournament < ActiveRecord::Base
end end
end end
def tournamentMatchGenerationError def match_generation_error
errorString = "There is a tournament error." errorString = "There is a tournament error."
if poolToBracketWeightsWithTooManyWrestlers != nil if pool_to_bracket_weights_with_too_many_wrestlers != nil
errorString = errorString + " The following weights have too many wrestlers " errorString = errorString + " The following weights have too many wrestlers "
poolToBracketWeightsWithTooManyWrestlers.each do |w| pool_to_bracket_weights_with_too_many_wrestlers.each do |w|
errorString = errorString + "#{w.max} " errorString = errorString + "#{w.max} "
end end
return errorString return errorString

View File

@@ -10,18 +10,18 @@ class Weight < ActiveRecord::Base
HS_WEIGHT_CLASSES = [106,113,120,126,132,138,145,152,160,170,182,195,220,285] HS_WEIGHT_CLASSES = [106,113,120,126,132,138,145,152,160,170,182,195,220,285]
before_destroy do before_destroy do
self.tournament.destroyAllMatches self.tournament.destroy_all_matches
end end
before_save do before_save do
# self.tournament.destroyAllMatches # self.tournament.destroy_all_matches
end end
def pools_with_bye def pools_with_bye
pool = 1 pool = 1
pools_with_a_bye = [] pools_with_a_bye = []
until pool > self.pools do until pool > self.pools do
if wrestlersForPool(pool).first.hasAPoolBye if wrestlers_in_pool(pool).first.has_a_pool_bye
pools_with_a_bye << pool pools_with_a_bye << pool
end end
pool = pool + 1 pool = pool + 1
@@ -29,19 +29,19 @@ class Weight < ActiveRecord::Base
pools_with_a_bye pools_with_a_bye
end end
def wrestlersForPool(poolNumber) def wrestlers_in_pool(pool_number)
#For some reason this does not work #For some reason this does not work
# wrestlers.select{|w| w.pool == poolNumber} # wrestlers.select{|w| w.pool == pool_number}
#This does... #This does...
weightWrestlers = Wrestler.where(:weight_id => self.id) weight_wrestlers = Wrestler.where(:weight_id => self.id)
weightWrestlers.select{|w| w.pool == poolNumber} weight_wrestlers.select{|w| w.pool == pool_number}
end end
def allPoolMatchesFinished(pool) def all_pool_matches_finished(pool)
@wrestlers = wrestlersForPool(pool) @wrestlers = wrestlers_in_pool(pool)
@wrestlers.each do |w| @wrestlers.each do |w|
if w.poolMatches.size != w.finishedPoolMatches.size if w.pool_matches.size != w.finished_pool_matches.size
return false return false
end end
end end
@@ -59,14 +59,14 @@ class Weight < ActiveRecord::Base
end end
end end
def poolSeedOrder(pool) def pool_wrestlers_sorted_by_bracket_line(pool)
# wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]} # wrestlers_in_pool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
return wrestlersForPool(pool).sort_by{|w|w.bracket_line} return wrestlers_in_pool(pool).sort_by{|w|w.bracket_line}
end end
def swapWrestlers(wrestler1_id,wrestler2_id) def swap_wrestlers_bracket_lines(wrestler1_id,wrestler2_id)
SwapWrestlers.new.swapWrestlers(wrestler1_id,wrestler2_id) SwapWrestlers.new.swap_wrestlers_bracket_lines(wrestler1_id,wrestler2_id)
end end
@@ -86,13 +86,13 @@ class Weight < ActiveRecord::Base
end end
end end
def poolRounds(matches) def pool_rounds(matches)
@matchups = matches.select{|m| m.weight_id == self.id} matchups = matches.select{|m| m.weight_id == self.id}
@poolMatches = @matchups.select{|m| m.bracket_position == "Pool"} pool_matches = matchups.select{|m| m.bracket_position == "Pool"}
return @poolMatches.sort_by{|m| m.round}.last.round return pool_matches.sort_by{|m| m.round}.last.round
end end
def totalRounds(matches) def total_rounds(matches)
@matchups = matches.select{|m| m.weight_id == self.id} @matchups = matches.select{|m| m.weight_id == self.id}
@lastRound = matches.sort_by{|m| m.round}.last.round @lastRound = matches.sort_by{|m| m.round}.last.round
count = 0 count = 0
@@ -106,11 +106,11 @@ class Weight < ActiveRecord::Base
return count return count
end end
def poolOrder(pool) def pool_placement_order(pool)
PoolOrder.new(wrestlersForPool(pool)).getPoolOrder PoolOrder.new(wrestlers_in_pool(pool)).getPoolOrder
end end
def wrestlersWithoutPool def wrestlers_without_pool_assignment
wrestlers.select{|w| w.pool == nil} wrestlers.select{|w| w.pool == nil}
end end

View File

@@ -9,102 +9,102 @@ class Wrestler < ActiveRecord::Base
validates :name, :weight_id, :school_id, presence: true validates :name, :weight_id, :school_id, presence: true
before_destroy do before_destroy do
# self.tournament.destroyAllMatches # self.tournament.destroy_all_matches
end end
before_create do before_create do
# self.tournament.destroyAllMatches # self.tournament.destroy_all_matches
end end
def lastFinishedMatch def last_finished_match
allMatches.select{|m| m.finished == 1}.sort_by{|m| m.bout_number}.last all_matches.select{|m| m.finished == 1}.sort_by{|m| m.bout_number}.last
end end
def totalTeamPoints def total_team_points
CalculateWrestlerTeamScore.new(self).totalScore CalculateWrestlerTeamScore.new(self).totalScore
end end
def teamPointsEarned def team_points_earned
CalculateWrestlerTeamScore.new(self).earnedPoints CalculateWrestlerTeamScore.new(self).earnedPoints
end end
def placementPoints def placement_points
CalculateWrestlerTeamScore.new(self).placementPoints CalculateWrestlerTeamScore.new(self).placement_points
end end
def totalDeductedPoints def total_points_deducted
CalculateWrestlerTeamScore.new(self).deductedPoints CalculateWrestlerTeamScore.new(self).deductedPoints
end end
def nextMatch def next_match
unfinishedMatches.first unfinished_matches.first
end end
def nextMatchPositionNumber def next_match_position_number
pos = lastMatch.bracket_position_number pos = last_match.bracket_position_number
return (pos/2.0) return (pos/2.0)
end end
def lastMatch def last_match
finishedMatches.sort_by{|m| m.round}.reverse.first finished_matches.sort_by{|m| m.round}.reverse.first
end end
def winnerOfLastMatch? def winner_of_last_match?
if lastMatch.winner_id == self.id if last_match.winner_id == self.id
return true return true
else else
return false return false
end end
end end
def nextMatchBoutNumber def next_match_bout_number
if nextMatch if next_match
nextMatch.bout_number next_match.bout_number
else else
"" ""
end end
end end
def nextMatchMatName def next_match_mat_name
if nextMatch if next_match
nextMatch.mat_assigned next_match.mat_assigned
else else
"" ""
end end
end end
def unfinishedMatches def unfinished_matches
allMatches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number} all_matches.select{|m| m.finished != 1}.sort_by{|m| m.bout_number}
end end
def resultByBout(bout) def result_by_bout(bout)
bout_match = allMatches.select{|m| m.bout_number == bout and m.finished == 1} bout_match = all_matches.select{|m| m.bout_number == bout and m.finished == 1}
if bout_match.size == 0 if bout_match.size == 0
return "" return ""
end end
if bout_match.first.winner_id == self.id if bout_match.first.winner_id == self.id
return "W #{bout_match.first.bracketScore}" return "W #{bout_match.first.bracket_score_string}"
end end
if bout_match.first.winner_id != self.id if bout_match.first.winner_id != self.id
return "L #{bout_match.first.bracketScore}" return "L #{bout_match.first.bracket_score_string}"
end end
end end
def matchAgainst(opponent) def match_against(opponent)
allMatches.select{|m| m.w1 == opponent.id or m.w2 == opponent.id} all_matches.select{|m| m.w1 == opponent.id or m.w2 == opponent.id}
end end
def isWrestlingThisRound(matchRound) def is_wrestling_this_round(matchRound)
if allMatches.blank? if all_matches.blank?
return false return false
else else
return true return true
end end
end end
def boutByRound(round) def bout_by_round(round)
round_match = allMatches.select{|m| m.round == round}.first round_match = all_matches.select{|m| m.round == round}.first
if round_match.blank? if round_match.blank?
return "BYE" return "BYE"
else else
@@ -112,93 +112,93 @@ class Wrestler < ActiveRecord::Base
end end
end end
def allMatches def all_matches
return matches.select{|m| m.w1 == self.id or m.w2 == self.id} return matches.select{|m| m.w1 == self.id or m.w2 == self.id}
end end
def poolMatches def pool_matches
pool_matches = allMatches.select{|m| m.bracket_position == "Pool"} all_weight_pool_matches = all_matches.select{|m| m.bracket_position == "Pool"}
pool_matches.select{|m| m.poolNumber == self.pool} all_weight_pool_matches.select{|m| m.pool_number == self.pool}
end end
def hasAPoolBye def has_a_pool_bye
if weight.poolRounds(matches) > poolMatches.size if weight.pool_rounds(matches) > pool_matches.size
return true return true
else else
return false return false
end end
end end
def championshipAdvancementWins def championship_advancement_wins
matchesWon.select{|m| m.bracket_position == "Quarter" or m.bracket_position == "Semis"} matches_won.select{|m| m.bracket_position == "Quarter" or m.bracket_position == "Semis"}
end end
def consoAdvancementWins def consolation_advancement_wins
matchesWon.select{|m| m.bracket_position == "Conso Semis"} matches_won.select{|m| m.bracket_position == "Conso Semis"}
end end
def finishedMatches def finished_matches
allMatches.select{|m| m.finished == 1} all_matches.select{|m| m.finished == 1}
end end
def finishedBracketMatches def finished_bracket_matches
finishedMatches.select{|m| m.bracket_position != "Pool"} finished_matches.select{|m| m.bracket_position != "Pool"}
end end
def finishedPoolMatches def finished_pool_matches
finishedMatches.select{|m| m.bracket_position == "Pool"} finished_matches.select{|m| m.bracket_position == "Pool"}
end end
def matchesWon def matches_won
allMatches.select{|m| m.winner_id == self.id} all_matches.select{|m| m.winner_id == self.id}
end end
def poolWins def pool_wins
matchesWon.select{|m| m.bracket_position == "Pool"} matches_won.select{|m| m.bracket_position == "Pool"}
end end
def pinWins def pin_wins
matchesWon.select{|m| m.win_type == "Pin" || m.win_type == "Forfeit" || m.win_type == "Injury Default" || m.win_type == "Default" || m.win_type == "DQ"} matches_won.select{|m| m.win_type == "Pin" || m.win_type == "Forfeit" || m.win_type == "Injury Default" || m.win_type == "Default" || m.win_type == "DQ"}
end end
def techWins def tech_wins
matchesWon.select{|m| m.win_type == "Tech Fall" } matches_won.select{|m| m.win_type == "Tech Fall" }
end end
def majorWins def major_wins
matchesWon.select{|m| m.win_type == "Major" } matches_won.select{|m| m.win_type == "Major" }
end end
def decisionWins def decision_wins
matchesWon.select{|m| m.win_type == "Decision" } matches_won.select{|m| m.win_type == "Decision" }
end end
def decisionPointsScored def decision_points_scored
pointsScored = 0 points_scored = 0
decisionWins.each do |m| decision_wins.each do |m|
scoreOfMatch = m.score.delete(" ") score_of_match = m.score.delete(" ")
scoreOne = scoreOfMatch.partition('-').first.to_i score_one = score_of_match.partition('-').first.to_i
scoreTwo = scoreOfMatch.partition('-').last.to_i score_two = score_of_match.partition('-').last.to_i
if scoreOne > scoreTwo if score_one > score_two
pointsScored = pointsScored + scoreOne points_scored = points_scored + score_one
elsif scoreTwo > scoreOne elsif score_two > score_one
pointsScored = pointsScored + scoreTwo points_scored = points_scored + score_two
end end
end end
pointsScored points_scored
end end
def fastestPin def fastest_pin
pinWins.sort_by{|m| m.pinTime}.first pin_wins.sort_by{|m| m.pin_time_in_seconds}.first
end end
def seasonWinPercentage def season_win_percentage
win = self.season_win.to_f win = self.season_win.to_f
loss = self.season_loss.to_f loss = self.season_loss.to_f
if win > 0 and loss != nil if win > 0 and loss != nil
matchTotal = win + loss match_total = win + loss
percentageDec = win / matchTotal percentage_dec = win / match_total
percentage = percentageDec * 100 percentage = percentage_dec * 100
return percentage.to_i return percentage.to_i
elsif self.season_win == 0 elsif self.season_win == 0
return 0 return 0

View File

@@ -5,7 +5,7 @@ class AdvanceWrestler
end end
def advance def advance
PoolAdvance.new(@wrestler,@wrestler.lastMatch).advanceWrestler if @tournament.tournament_type == "Pool to bracket" PoolAdvance.new(@wrestler,@wrestler.last_match).advanceWrestler if @tournament.tournament_type == "Pool to bracket"
end end
if Rails.env.production? if Rails.env.production?
handle_asynchronously :advance handle_asynchronously :advance

View File

@@ -6,10 +6,10 @@ class PoolAdvance
end end
def advanceWrestler def advanceWrestler
if @wrestler.weight.allPoolMatchesFinished(@wrestler.pool) && @wrestler.finishedBracketMatches.size == 0 if @wrestler.weight.all_pool_matches_finished(@wrestler.pool) && @wrestler.finished_bracket_matches.size == 0
poolToBracketAdvancment poolToBracketAdvancment
end end
if @wrestler.finishedBracketMatches.size > 0 if @wrestler.finished_bracket_matches.size > 0
bracketAdvancment bracketAdvancment
end end
end end
@@ -17,15 +17,15 @@ class PoolAdvance
def poolToBracketAdvancment def poolToBracketAdvancment
pool = @wrestler.pool pool = @wrestler.pool
if @wrestler.weight.wrestlers.size > 6 if @wrestler.weight.wrestlers.size > 6
poolOrder = @wrestler.weight.poolOrder(pool) pool_placement_order = @wrestler.weight.pool_placement_order(pool)
#Take pool order and move winner and runner up to correct match based on w1_name and w2_name #Take pool order and move winner and runner up to correct match based on w1_name and w2_name
matches = @wrestler.weight.matches matches = @wrestler.weight.matches
winnerMatch = matches.select{|m| m.loser1_name == "Winner Pool #{pool}" || m.loser2_name == "Winner Pool #{pool}"}.first winnerMatch = matches.select{|m| m.loser1_name == "Winner Pool #{pool}" || m.loser2_name == "Winner Pool #{pool}"}.first
runnerUpMatch = matches.select{|m| m.loser1_name == "Runner Up Pool #{pool}" || m.loser2_name == "Runner Up Pool #{pool}"}.first runnerUpMatch = matches.select{|m| m.loser1_name == "Runner Up Pool #{pool}" || m.loser2_name == "Runner Up Pool #{pool}"}.first
winner = poolOrder.first winner = pool_placement_order.first
runnerUp = poolOrder.second runnerUp = pool_placement_order.second
runnerUpMatch.replaceLoserNameWithWrestler(runnerUp,"Runner Up Pool #{pool}") runnerUpMatch.replace_loser_name_with_wrestler(runnerUp,"Runner Up Pool #{pool}")
winnerMatch.replaceLoserNameWithWrestler(winner,"Winner Pool #{pool}") winnerMatch.replace_loser_name_with_wrestler(winner,"Winner Pool #{pool}")
end end
end end
@@ -39,37 +39,37 @@ class PoolAdvance
end end
def winnerAdvance def winnerAdvance
if @wrestler.lastMatch.bracket_position == "Quarter" if @wrestler.last_match.bracket_position == "Quarter"
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Semis",@wrestler.nextMatchPositionNumber.ceil,@wrestler.weight_id).first new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","Semis",@wrestler.next_match_position_number.ceil,@wrestler.weight_id).first
updateNewMatch(new_match) updateNewMatch(new_match)
end end
if @wrestler.lastMatch.bracket_position == "Semis" if @wrestler.last_match.bracket_position == "Semis"
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","1/2",@wrestler.nextMatchPositionNumber.ceil,@wrestler.weight_id).first new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","1/2",@wrestler.next_match_position_number.ceil,@wrestler.weight_id).first
updateNewMatch(new_match) updateNewMatch(new_match)
end end
if @wrestler.lastMatch.bracket_position == "Conso Semis" if @wrestler.last_match.bracket_position == "Conso Semis"
new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","5/6",@wrestler.nextMatchPositionNumber.ceil,@wrestler.weight_id).first new_match = Match.where("bracket_position = ? AND bracket_position_number = ? AND weight_id = ?","5/6",@wrestler.next_match_position_number.ceil,@wrestler.weight_id).first
updateNewMatch(new_match) updateNewMatch(new_match)
end end
end end
def updateNewMatch(match) def updateNewMatch(match)
if @wrestler.nextMatchPositionNumber == @wrestler.nextMatchPositionNumber.ceil if @wrestler.next_match_position_number == @wrestler.next_match_position_number.ceil
match.w2 = @wrestler.id match.w2 = @wrestler.id
match.save match.save
end end
if @wrestler.nextMatchPositionNumber != @wrestler.nextMatchPositionNumber.ceil if @wrestler.next_match_position_number != @wrestler.next_match_position_number.ceil
match.w1 = @wrestler.id match.w1 = @wrestler.id
match.save match.save
end end
end end
def loserAdvance def loserAdvance
bout = @wrestler.lastMatch.bout_number bout = @wrestler.last_match.bout_number
next_match = Match.where("(loser1_name = ? OR loser2_name = ?) AND weight_id = ?","Loser of #{bout}","Loser of #{bout}",@wrestler.weight_id) next_match = Match.where("(loser1_name = ? OR loser2_name = ?) AND weight_id = ?","Loser of #{bout}","Loser of #{bout}",@wrestler.weight_id)
if next_match.size > 0 if next_match.size > 0
next_match.first.replaceLoserNameWithWrestler(@wrestler,"Loser of #{bout}") next_match.first.replace_loser_name_with_wrestler(@wrestler,"Loser of #{bout}")
end end
end end
end end

View File

@@ -13,7 +13,7 @@ class PoolOrder
def setOriginalPoints def setOriginalPoints
@wrestlers.each do |w| @wrestlers.each do |w|
w.poolAdvancePoints = w.poolWins.size w.poolAdvancePoints = w.pool_wins.size
end end
end end
@@ -50,7 +50,7 @@ class PoolOrder
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostTechs } ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostTechs }
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostMajors } ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostMajors }
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostDecisionPointsScored } ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { mostDecisionPointsScored }
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { fastestPin } ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { fastest_pin }
ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip } ifWrestlersWithSamePointsIsSameAsOriginal(originalTieSize) { coinFlip }
end end
@@ -58,7 +58,7 @@ class PoolOrder
def headToHead def headToHead
wrestlersWithSamePoints.each do |wr| wrestlersWithSamePoints.each do |wr|
otherWrestler = wrestlersWithSamePoints.select{|w| w.id != wr.id}.first otherWrestler = wrestlersWithSamePoints.select{|w| w.id != wr.id}.first
if wr.matchAgainst(otherWrestler).first.winner_id == wr.id if wr.match_against(otherWrestler).first.winner_id == wr.id
addPointsToWrestlersAhead(wr) addPointsToWrestlersAhead(wr)
addPoints(wr) addPoints(wr)
end end
@@ -79,10 +79,10 @@ class PoolOrder
def deductedPoints def deductedPoints
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.totalDeductedPoints pointsArray << w.total_points_deducted
end end
leastPoints = pointsArray.min leastPoints = pointsArray.min
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.totalDeductedPoints == leastPoints} wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.total_points_deducted == leastPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)
@@ -92,39 +92,39 @@ class PoolOrder
def mostDecisionPointsScored def mostDecisionPointsScored
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.decisionPointsScored pointsArray << w.decision_points_scored
end end
mostPoints = pointsArray.max mostPoints = pointsArray.max
wrestlersWithMostPoints = wrestlersWithSamePoints.select{|w| w.decisionPointsScored == mostPoints} wrestlersWithMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == mostPoints}
addPointsToWrestlersAhead(wrestlersWithMostPoints.first) addPointsToWrestlersAhead(wrestlersWithMostPoints.first)
wrestlersWithMostPoints.each do |wr| wrestlersWithMostPoints.each do |wr|
addPoints(wr) addPoints(wr)
end end
secondPoints = pointsArray.sort[-2] secondPoints = pointsArray.sort[-2]
wrestlersWithSecondMostPoints = wrestlersWithSamePoints.select{|w| w.decisionPointsScored == secondPoints} wrestlersWithSecondMostPoints = wrestlersWithSamePoints.select{|w| w.decision_points_scored == secondPoints}
addPointsToWrestlersAhead(wrestlersWithSecondMostPoints.first) addPointsToWrestlersAhead(wrestlersWithSecondMostPoints.first)
wrestlersWithSecondMostPoints.each do |wr| wrestlersWithSecondMostPoints.each do |wr|
addPoints(wr) addPoints(wr)
end end
end end
def fastestPin def fastest_pin
wrestlersWithSamePointsWithPins = [] wrestlersWithSamePointsWithPins = []
wrestlersWithSamePoints.each do |wr| wrestlersWithSamePoints.each do |wr|
if wr.pinWins.size > 0 if wr.pin_wins.size > 0
wrestlersWithSamePointsWithPins << wr wrestlersWithSamePointsWithPins << wr
end end
end end
if wrestlersWithSamePointsWithPins.size > 0 if wrestlersWithSamePointsWithPins.size > 0
fastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastestPin.pinTime}.first.fastestPin fastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastest_pin.pin_time_in_seconds}.first.fastest_pin
secondFastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastestPin.pinTime}.second.fastestPin secondFastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastest_pin.pin_time_in_seconds}.second.fastest_pin
wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastestPin.pinTime == fastest.pinTime} wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == fastest.pin_time_in_seconds}
addPointsToWrestlersAhead(wrestlersWithFastestPin.first) addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
wrestlersWithFastestPin.each do |wr| wrestlersWithFastestPin.each do |wr|
addPoints(wr) addPoints(wr)
end end
wrestlersWithSecondFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastestPin.pinTime == secondFastest.pinTime} wrestlersWithSecondFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastest_pin.pin_time_in_seconds == secondFastest.pin_time_in_seconds}
addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first) addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first)
wrestlersWithSecondFastestPin.each do |wr| wrestlersWithSecondFastestPin.each do |wr|
addPoints(wr) addPoints(wr)
@@ -135,10 +135,10 @@ class PoolOrder
def teamPoints def teamPoints
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.teamPointsEarned pointsArray << w.team_points_earned
end end
mostPoints = pointsArray.max mostPoints = pointsArray.max
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.teamPointsEarned == mostPoints} wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.team_points_earned == mostPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)
@@ -148,10 +148,10 @@ class PoolOrder
def mostFalls def mostFalls
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.pinWins.size pointsArray << w.pin_wins.size
end end
mostPoints = pointsArray.max mostPoints = pointsArray.max
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.pinWins.size == mostPoints} wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.pin_wins.size == mostPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)
@@ -161,10 +161,10 @@ class PoolOrder
def mostTechs def mostTechs
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.techWins.size pointsArray << w.tech_wins.size
end end
mostPoints = pointsArray.max mostPoints = pointsArray.max
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.techWins.size == mostPoints} wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.tech_wins.size == mostPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)
@@ -174,10 +174,10 @@ class PoolOrder
def mostMajors def mostMajors
pointsArray = [] pointsArray = []
wrestlersWithSamePoints.each do |w| wrestlersWithSamePoints.each do |w|
pointsArray << w.majorWins.size pointsArray << w.major_wins.size
end end
mostPoints = pointsArray.max mostPoints = pointsArray.max
wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.majorWins.size == mostPoints} wrestlersWithLeastDeductedPoints = wrestlersWithSamePoints.select{|w| w.major_wins.size == mostPoints}
addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first) addPointsToWrestlersAhead(wrestlersWithLeastDeductedPoints.first)
wrestlersWithLeastDeductedPoints.each do |wr| wrestlersWithLeastDeductedPoints.each do |wr|
addPoints(wr) addPoints(wr)

View File

@@ -53,7 +53,7 @@ class GenerateTournamentMatches
end end
def moveFinalsMatchesToLastRound def moveFinalsMatchesToLastRound
finalsRound = @tournament.totalRounds finalsRound = @tournament.total_rounds
finalsMatches = @tournament.matches.reload.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"} finalsMatches = @tournament.matches.reload.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| finalsMatches. each do |m|
m.round = finalsRound m.round = finalsRound
@@ -66,7 +66,7 @@ class GenerateTournamentMatches
if matsToAssign.count > 0 if matsToAssign.count > 0
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4 until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4
matsToAssign.sort_by{|m| m.id}.each do |m| matsToAssign.sort_by{|m| m.id}.each do |m|
m.assignNextMatch m.assign_next_match
end end
end end
end end

View File

@@ -15,9 +15,9 @@ class PoolGeneration
end end
def roundRobin def roundRobin
wrestlers = @weight.wrestlersForPool(@pool) wrestlers = @weight.wrestlers_in_pool(@pool)
poolMatches = RoundRobinTournament.schedule(wrestlers).reverse pool_matches = RoundRobinTournament.schedule(wrestlers).reverse
poolMatches.each_with_index do |b, index| pool_matches.each_with_index do |b, index|
round = index + 1 round = index + 1
bouts = b.map bouts = b.map
bouts.each do |bout| bouts.each do |bout|

View File

@@ -30,14 +30,14 @@ class PoolToBracketMatchGeneration
def setOriginalSeedsToWrestleLastPoolRound(weight) def setOriginalSeedsToWrestleLastPoolRound(weight)
pool = 1 pool = 1
until pool > weight.pools until pool > weight.pools
wrestler1 = weight.poolSeedOrder(pool).first wrestler1 = weight.pool_wrestlers_sorted_by_bracket_line(pool).first
wrestler2 = weight.poolSeedOrder(pool).second wrestler2 = weight.pool_wrestlers_sorted_by_bracket_line(pool).second
match = wrestler1.poolMatches.sort_by{|m| m.round}.last match = wrestler1.pool_matches.sort_by{|m| m.round}.last
if match.w1 != wrestler2.id or match.w2 != wrestler2.id if match.w1 != wrestler2.id or match.w2 != wrestler2.id
if match.w1 == wrestler1.id if match.w1 == wrestler1.id
SwapWrestlers.new.swapWrestlers(match.w2,wrestler2.id) SwapWrestlers.new.swap_wrestlers_bracket_lines(match.w2,wrestler2.id)
elsif match.w2 == wrestler1.id elsif match.w2 == wrestler1.id
SwapWrestlers.new.swapWrestlers(match.w1,wrestler2.id) SwapWrestlers.new.swap_wrestlers_bracket_lines(match.w1,wrestler2.id)
end end
end end
pool += 1 pool += 1

View File

@@ -5,11 +5,11 @@ class GeneratePoolNumbers
def savePoolNumbers def savePoolNumbers
if @weight.pools == 4 if @weight.pools == 4
saveFourPoolNumbers(@weight.wrestlersWithoutPool) saveFourPoolNumbers(@weight.wrestlers_without_pool_assignment)
elsif @weight.pools == 2 elsif @weight.pools == 2
saveTwoPoolNumbers(@weight.wrestlersWithoutPool) saveTwoPoolNumbers(@weight.wrestlers_without_pool_assignment)
elsif @weight.pools == 1 elsif @weight.pools == 1
saveOnePoolNumbers(@weight.wrestlersWithoutPool) saveOnePoolNumbers(@weight.wrestlers_without_pool_assignment)
end end
end end

View File

@@ -13,7 +13,7 @@ class CalculateWrestlerTeamScore
end end
def earnedPoints def earnedPoints
return poolPoints + bracketPoints + placementPoints + bonusWinPoints + byePoints return poolPoints + bracketPoints + placement_points + bonusWinPoints + byePoints
end end
def deductedPoints def deductedPoints
@@ -24,17 +24,17 @@ class CalculateWrestlerTeamScore
points points
end end
def placementPoints def placement_points
PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket" PoolBracketPlacementPoints.new(@wrestler).calcPoints if @tournament.tournament_type == "Pool to bracket"
end end
def bracketPoints def bracketPoints
(@wrestler.championshipAdvancementWins.size * 2) + (@wrestler.consoAdvancementWins.size * 1) (@wrestler.championship_advancement_wins.size * 2) + (@wrestler.consolation_advancement_wins.size * 1)
end end
def poolPoints def poolPoints
if @tournament.tournament_type == "Pool to bracket" if @tournament.tournament_type == "Pool to bracket"
(@wrestler.poolWins.size * 2) (@wrestler.pool_wins.size * 2)
else else
0 0
end end
@@ -42,7 +42,7 @@ class CalculateWrestlerTeamScore
def byePoints def byePoints
if @tournament.tournament_type == "Pool to bracket" if @tournament.tournament_type == "Pool to bracket"
if @wrestler.poolWins.size >= 1 and @wrestler.hasAPoolBye == true if @wrestler.pool_wins.size >= 1 and @wrestler.has_a_pool_bye == true
2 2
else else
0 0
@@ -53,7 +53,7 @@ class CalculateWrestlerTeamScore
end end
def bonusWinPoints def bonusWinPoints
(@wrestler.pinWins.size * 2) + (@wrestler.techWins.size * 1.5) + (@wrestler.majorWins.size * 1) (@wrestler.pin_wins.size * 2) + (@wrestler.tech_wins.size * 1.5) + (@wrestler.major_wins.size * 1)
end end
end end

View File

@@ -16,7 +16,7 @@ class PoolBracketPlacementPoints
if @bracket == "fourPoolsToSemi" if @bracket == "fourPoolsToSemi"
whilePointsAreZero { @points = fourPoolsToSemi } whilePointsAreZero { @points = fourPoolsToSemi }
end end
if @wrestler.weight.wrestlers.size <= 6 && @wrestler.weight.allPoolMatchesFinished(1) if @wrestler.weight.wrestlers.size <= 6 && @wrestler.weight.all_pool_matches_finished(1)
whilePointsAreZero { @points = onePool } whilePointsAreZero { @points = onePool }
end end
return @points return @points
@@ -29,11 +29,11 @@ class PoolBracketPlacementPoints
end end
def bracket_position_size(bracket_position_name) def bracket_position_size(bracket_position_name)
@wrestler.allMatches.select{|m| m.bracket_position == bracket_position_name}.size @wrestler.all_matches.select{|m| m.bracket_position == bracket_position_name}.size
end end
def won_bracket_position_size(bracket_position_name) def won_bracket_position_size(bracket_position_name)
@wrestler.matchesWon.select{|m| m.bracket_position == bracket_position_name}.size @wrestler.matches_won.select{|m| m.bracket_position == bracket_position_name}.size
end end
def fourPoolsToQuarter def fourPoolsToQuarter
@@ -67,14 +67,14 @@ class PoolBracketPlacementPoints
end end
def onePool def onePool
poolOrder = @wrestler.weight.poolOrder(1) pool_placement_order = @wrestler.weight.pool_placement_order(1)
if @wrestler == poolOrder.first if @wrestler == pool_placement_order.first
return firstPlace return firstPlace
elsif @wrestler == poolOrder.second elsif @wrestler == pool_placement_order.second
return secondPlace return secondPlace
elsif @wrestler == poolOrder.third elsif @wrestler == pool_placement_order.third
return thirdPlace return thirdPlace
elsif @wrestler == poolOrder.fourth elsif @wrestler == pool_placement_order.fourth
return fourthPlace return fourthPlace
end end
return 0 return 0

View File

@@ -2,7 +2,7 @@ class SwapWrestlers
attr_accessor :wrestler1_id, :wrestler2_id attr_accessor :wrestler1_id, :wrestler2_id
def swapWrestlers(wrestler1_id,wrestler2_id) def swap_wrestlers_bracket_lines(wrestler1_id,wrestler2_id)
w1 = Wrestler.find(wrestler1_id) w1 = Wrestler.find(wrestler1_id)
w2 = Wrestler.find(wrestler2_id) w2 = Wrestler.find(wrestler2_id)
@@ -12,15 +12,15 @@ class SwapWrestlers
w3.original_seed = w1.original_seed w3.original_seed = w1.original_seed
w3.bracket_line = w1.bracket_line w3.bracket_line = w1.bracket_line
w3.pool = w1.pool w3.pool = w1.pool
swapWrestlerMatches(w1.allMatches,w1.id,w3.id) swapWrestlerMatches(w1.all_matches,w1.id,w3.id)
#Swap wrestler 1 and wrestler 2 #Swap wrestler 1 and wrestler 2
swapWrestlerMatches(w2.allMatches,w2.id,w1.id) swapWrestlerMatches(w2.all_matches,w2.id,w1.id)
w1.bracket_line = w2.bracket_line w1.bracket_line = w2.bracket_line
w1.pool = w2.pool w1.pool = w2.pool
swapWrestlerMatches(w3.allMatches,w3.id,w2.id) swapWrestlerMatches(w3.all_matches,w3.id,w2.id)
w2.bracket_line = w3.bracket_line w2.bracket_line = w3.bracket_line
w2.pool = w3.pool w2.pool = w3.pool

View File

@@ -20,7 +20,7 @@ json.cache! ["api_tournament", @tournament] do
json.original_seed wrestler.original_seed json.original_seed wrestler.original_seed
json.criteria wrestler.criteria json.criteria wrestler.criteria
json.extra wrestler.extra json.extra wrestler.extra
json.seasonWinPercentage wrestler.seasonWinPercentage json.season_win_percentage wrestler.season_win_percentage
json.season_win wrestler.season_win json.season_win wrestler.season_win
json.season_loss wrestler.season_loss json.season_loss wrestler.season_loss
end end
@@ -28,7 +28,7 @@ json.cache! ["api_tournament", @tournament] do
json.mats @tournament.mats do |mat| json.mats @tournament.mats do |mat|
json.name mat.name json.name mat.name
json.unfinishedMatches mat.unfinishedMatches do |match| json.unfinished_matches mat.unfinished_matches do |match|
json.bout_number match.bout_number json.bout_number match.bout_number
json.w1_name match.w1_name json.w1_name match.w1_name
json.w2_name match.w2_name json.w2_name match.w2_name

View File

@@ -17,11 +17,11 @@
<th><%= @w1.name %> <select id="w1-color" onchange="changeW1Color(this)"> <th><%= @w1.name %> <select id="w1-color" onchange="changeW1Color(this)">
<option value="green">Green</option> <option value="green">Green</option>
<option value="red">Red</option> <option value="red">Red</option>
</select><br>Last Match: <%= if @w1.lastMatch != nil then time_ago_in_words(@w1.lastMatch.updated_at) end%></th> </select><br>Last Match: <%= if @w1.last_match != nil then time_ago_in_words(@w1.last_match.updated_at) end%></th>
<th><%= @w2.name %> <select id="w2-color" onchange="changeW2Color(this)"> <th><%= @w2.name %> <select id="w2-color" onchange="changeW2Color(this)">
<option value="red">Red</option> <option value="red">Red</option>
<option value="green">Green</option> <option value="green">Green</option>
</select><br>Last Match: <%= if @w2.lastMatch != nil then time_ago_in_words(@w2.lastMatch.updated_at) end%></th> </select><br>Last Match: <%= if @w2.last_match != nil then time_ago_in_words(@w2.last_match.updated_at) end%></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View File

@@ -17,11 +17,11 @@
<th><%= @w1.name %> - <%= @w1.school.name %> <select id="w1-color" onchange="changeW1Color(this)"> <th><%= @w1.name %> - <%= @w1.school.name %> <select id="w1-color" onchange="changeW1Color(this)">
<option value="green">Green</option> <option value="green">Green</option>
<option value="red">Red</option> <option value="red">Red</option>
</select><br>Last Match: <%= if @w1.lastMatch != nil then time_ago_in_words(@w1.lastMatch.updated_at) end%></th> </select><br>Last Match: <%= if @w1.last_match != nil then time_ago_in_words(@w1.last_match.updated_at) end%></th>
<th><%= @w2.name %> - <%= @w2.school.name %> <select id="w2-color" onchange="changeW2Color(this)"> <th><%= @w2.name %> - <%= @w2.school.name %> <select id="w2-color" onchange="changeW2Color(this)">
<option value="red">Red</option> <option value="red">Red</option>
<option value="green">Green</option> <option value="green">Green</option>
</select><br>Last Match: <%= if @w2.lastMatch != nil then time_ago_in_words(@w2.lastMatch.updated_at) end%></th> </select><br>Last Match: <%= if @w2.last_match != nil then time_ago_in_words(@w2.last_match.updated_at) end%></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View File

@@ -13,7 +13,7 @@
<p> <p>
<strong>Team Points Deducted:</strong> <strong>Team Points Deducted:</strong>
<%= @school.totalDeductedPoints %> <%= @school.total_points_deducted %>
</p> </p>
<p> <p>
<strong>Score:</strong> <strong>Score:</strong>
@@ -57,11 +57,11 @@
<td> <td>
<%= wrestler.original_seed %> <%= wrestler.original_seed %>
</td> </td>
<td><%= wrestler.totalTeamPoints - wrestler.totalDeductedPoints %></td> <td><%= wrestler.total_team_points - wrestler.total_points_deducted %></td>
<td><% if wrestler.extra? == true %> <td><% if wrestler.extra? == true %>
Yes Yes
<% end %></td> <% end %></td>
<td><%= wrestler.nextMatchBoutNumber %> <%= wrestler.nextMatchMatName %></td> <td><%= wrestler.next_match_bout_number %> <%= wrestler.next_match_mat_name %></td>
<td> <td>
<%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %> <%= link_to 'Show', wrestler , :class=>"btn btn-default btn-sm" %>
<% if can? :manage, wrestler.school %> <% if can? :manage, wrestler.school %>

View File

@@ -18,13 +18,13 @@
</thead> </thead>
<tbody> <tbody>
<% @school.wrestlers.each do |wrestler| %> <% @school.wrestlers.each do |wrestler| %>
<% wrestler.allMatches.each do |m| %> <% wrestler.all_matches.each do |m| %>
<tr> <tr>
<td> <%= wrestler.name %> <td> <%= wrestler.name %>
<td><%= m.bout_number %></td> <td><%= m.bout_number %></td>
<td><%= m.bracket_position %></td> <td><%= m.bracket_position %></td>
<td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td> <td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td>
<td><%= wrestler.resultByBout(m.bout_number) %> <td><%= wrestler.result_by_bout(m.bout_number) %>
</tr> </tr>
<% end %> <% end %>
<% end %> <% end %>

View File

@@ -5,7 +5,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -17,7 +17,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -28,7 +28,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -37,7 +37,7 @@
<ul class="round round-4"> <ul class="round round-4">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %> <span></span></li> <li class="bracket-winner"><%= match.winner_name %> <span></span></li>
1st 1st
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -51,7 +51,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -60,7 +60,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"> <%= match.winnerName %><span></span></li> <li class="bracket-winner"> <%= match.winner_name %><span></span></li>
3rd 3rd
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -74,7 +74,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -86,7 +86,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -95,7 +95,7 @@
<ul class="round round-3"> <ul class="round round-3">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"> <%= match.winnerName %><span></span></li> <li class="bracket-winner"> <%= match.winner_name %><span></span></li>
5th 5th
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -109,7 +109,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -118,7 +118,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %> <span></span></li> <li class="bracket-winner"><%= match.winner_name %> <span></span></li>
7th 7th
<li>&nbsp;</li> <li>&nbsp;</li>

View File

@@ -5,7 +5,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -17,7 +17,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -26,7 +26,7 @@
<ul class="round round-3"> <ul class="round round-3">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
1st 1st
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -41,7 +41,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -50,7 +50,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
3rd 3rd
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -66,7 +66,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -78,7 +78,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -87,7 +87,7 @@
<ul class="round round-3"> <ul class="round round-3">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
5th 5th
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -101,7 +101,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -110,7 +110,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
7th 7th
<li>&nbsp;</li> <li>&nbsp;</li>

View File

@@ -1,8 +1,8 @@
<h5>Results</h5> <h5>Results</h5>
<br> <br>
<ol> <ol>
<li><%= @weight.poolOrder(1).first.name %></li> <li><%= @weight.pool_placement_order(1).first.name %></li>
<li><%= @weight.poolOrder(1).second.name %></li> <li><%= @weight.pool_placement_order(1).second.name %></li>
<li><%= @weight.poolOrder(1).third.name %></li> <li><%= @weight.pool_placement_order(1).third.name %></li>
<li><%= @weight.poolOrder(1).fourth.name %></li> <li><%= @weight.pool_placement_order(1).fourth.name %></li>
</ol> </ol>

View File

@@ -21,7 +21,7 @@
<% @round = 1 %> <% @round = 1 %>
<% until @matches.select{|m| m.round == @round}.blank? %> <% until @matches.select{|m| m.round == @round}.blank? %>
<% if @round <= @pools %> <% if @round <= @pools %>
<td><%= w.boutByRound(@round) %><br><%= w.resultByBout(w.boutByRound(@round)) %></td> <td><%= w.bout_by_round(@round) %><br><%= w.result_by_bout(w.bout_by_round(@round)) %></td>
<% end %> <% end %>
<% @round = @round + 1 %> <% @round = @round + 1 %>
<% end %> <% end %>

View File

@@ -5,7 +5,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -14,7 +14,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
1st 1st
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -28,7 +28,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -37,7 +37,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %> <span></span></li> <li class="bracket-winner"><%= match.winner_name %> <span></span></li>
3rd 3rd
<li>&nbsp;</li> <li>&nbsp;</li>

View File

@@ -5,7 +5,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -17,7 +17,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -26,7 +26,7 @@
<ul class="round round-3"> <ul class="round round-3">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
1st 1st
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -41,7 +41,7 @@
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="game game-top "><%= match.w1_name %> <span></span></li> <li class="game game-top "><%= match.w1_name %> <span></span></li>
<li><%= match.bout_number %> <%= match.bracketScore %>&nbsp;</li> <li><%= match.bout_number %> <%= match.bracket_score_string %>&nbsp;</li>
<li class="game game-bottom "><%= match.w2_name %><span></span></li> <li class="game game-bottom "><%= match.w2_name %><span></span></li>
<li>&nbsp;</li> <li>&nbsp;</li>
@@ -50,7 +50,7 @@
<ul class="round round-2"> <ul class="round round-2">
<li>&nbsp;</li> <li>&nbsp;</li>
<li class="bracket-winner"><%= match.winnerName %><span></span></li> <li class="bracket-winner"><%= match.winner_name %><span></span></li>
3rd 3rd
<li>&nbsp;</li> <li>&nbsp;</li>

View File

@@ -74,7 +74,7 @@ li:first-child,li:last-child {
<% @weight = w %> <% @weight = w %>
<% @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} %> <% @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} %>
<% @wrestlers = Wrestler.where(weight_id: @weight.id) %> <% @wrestlers = Wrestler.where(weight_id: @weight.id) %>
<% @pools = w.poolRounds(@matches) %> <% @pools = w.pool_rounds(@matches) %>
<%= render 'pool' %> <%= render 'pool' %>
</td> </td>

View File

@@ -65,7 +65,7 @@ li:first-child,li:last-child {
<td valign="top" style="padding: 10px;"> <td valign="top" style="padding: 10px;">
<% @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} %> <% @matches = @tournament.matches.select{|m| m.weight_id == @weight.id} %>
<% @wrestlers = Wrestler.where(weight_id: @weight.id) %> <% @wrestlers = Wrestler.where(weight_id: @weight.id) %>
<% @pools = @weight.poolRounds(@matches) %> <% @pools = @weight.pool_rounds(@matches) %>
<%= render 'pool' %> <%= render 'pool' %>
</td> </td>

View File

@@ -1,3 +1,3 @@
<%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %> <%= link_to "Back to #{@tournament.name}", "/tournaments/#{@tournament.id}", :class=>"btn btn-default" %>
<br><br> <br><br>
<%= @tournament.tournamentMatchGenerationError %> <%= @tournament.match_generation_error %>

View File

@@ -17,7 +17,7 @@
<% @schools.each do |school| %> <% @schools.each do |school| %>
<tr> <tr>
<td><%= school.name %></td> <td><%= school.name %></td>
<td><%= school.pageScore %></td> <td><%= school.page_score_string %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -29,10 +29,10 @@
<% @mats.each.map do |m| %> <% @mats.each.map do |m| %>
<tr> <tr>
<td><%= m.name %></td> <td><%= m.name %></td>
<td><% if m.unfinishedMatches.first %><strong><%=m.unfinishedMatches.first.bout_number%></strong> - <%= m.unfinishedMatches.first.weight_max %> lbs<br><%= m.unfinishedMatches.first.w1_name %> vs. <%= m.unfinishedMatches.first.w2_name %><% end %></td> <td><% if m.unfinished_matches.first %><strong><%=m.unfinished_matches.first.bout_number%></strong> - <%= m.unfinished_matches.first.weight_max %> lbs<br><%= m.unfinished_matches.first.w1_name %> vs. <%= m.unfinished_matches.first.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.second %><strong><%=m.unfinishedMatches.second.bout_number%></strong> - <%= m.unfinishedMatches.second.weight_max %> lbs<br><%= m.unfinishedMatches.second.w1_name %> vs. <%= m.unfinishedMatches.second.w2_name %><% end %></td> <td><% if m.unfinished_matches.second %><strong><%=m.unfinished_matches.second.bout_number%></strong> - <%= m.unfinished_matches.second.weight_max %> lbs<br><%= m.unfinished_matches.second.w1_name %> vs. <%= m.unfinished_matches.second.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.third %><strong><%=m.unfinishedMatches.third.bout_number%></strong> - <%= m.unfinishedMatches.third.weight_max %> lbs<br><%= m.unfinishedMatches.third.w1_name %> vs. <%= m.unfinishedMatches.third.w2_name %><% end %></td> <td><% if m.unfinished_matches.third %><strong><%=m.unfinished_matches.third.bout_number%></strong> - <%= m.unfinished_matches.third.weight_max %> lbs<br><%= m.unfinished_matches.third.w1_name %> vs. <%= m.unfinished_matches.third.w2_name %><% end %></td>
<td><% if m.unfinishedMatches.fourth %><strong><%=m.unfinishedMatches.fourth.bout_number%></strong> - <%= m.unfinishedMatches.fourth.weight_max %> lbs<br><%= m.unfinishedMatches.fourth.w1_name %> vs. <%= m.unfinishedMatches.fourth.w2_name %><% end %></td> <td><% if m.unfinished_matches.fourth %><strong><%=m.unfinished_matches.fourth.bout_number%></strong> - <%= m.unfinished_matches.fourth.weight_max %> lbs<br><%= m.unfinished_matches.fourth.w1_name %> vs. <%= m.unfinished_matches.fourth.w2_name %><% end %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -42,7 +42,7 @@
<% end %> <% end %>
</td> </td>
<td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td> <td><%= wrestler.season_win %>-<%= wrestler.season_loss %></td>
<td><%= wrestler.criteria %> Win <%= wrestler.seasonWinPercentage %>%</td> <td><%= wrestler.criteria %> Win <%= wrestler.season_win_percentage %>%</td>
<td><% if wrestler.extra? == true %> <td><% if wrestler.extra? == true %>
Yes Yes
<% end %></td> <% end %></td>

View File

@@ -55,7 +55,7 @@
</tr> </tr>
<tr> <tr>
<td>Placement Points</td> <td>Placement Points</td>
<td>+<%= @wrestler_points_calc.placementPoints %></td> <td>+<%= @wrestler_points_calc.placement_points %></td>
</tr> </tr>
<tr> <tr>
<td>Deducted Points</td> <td>Deducted Points</td>
@@ -86,12 +86,12 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @wrestler.allMatches.each do |m| %> <% @wrestler.all_matches.each do |m| %>
<tr> <tr>
<td><%= m.bout_number %></td> <td><%= m.bout_number %></td>
<td><%= m.bracket_position %></td> <td><%= m.bracket_position %></td>
<td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td> <td><%= m.list_w1_stats %><br><%= m.list_w2_stats %></td>
<td><%= @wrestler.resultByBout(m.bout_number) %> <td><%= @wrestler.result_by_bout(m.bout_number) %>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -62,7 +62,7 @@ class MatsControllerTest < ActionController::TestCase
end end
def wipe def wipe
@tournament.destroyAllMatches @tournament.destroy_all_matches
end end
test "logged in tournament owner should get edit mat page" do test "logged in tournament owner should get edit mat page" do

View File

@@ -52,7 +52,7 @@ class TournamentsControllerTest < ActionController::TestCase
end end
def wipe def wipe
@tournament.destroyAllMatches @tournament.destroy_all_matches
end end
test "logged in tournament owner can generate matches" do test "logged in tournament owner can generate matches" do

View File

@@ -289,49 +289,49 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
test "nine man outright finals advance" do test "nine man outright finals advance" do
nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler = Wrestler.where("name = ?", "Guy2").first wrestler = Wrestler.where("name = ?", "Guy2").first
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man outright conso finals advance" do test "nine man outright conso finals advance" do
nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler = Wrestler.where("name = ?", "Guy8").first wrestler = Wrestler.where("name = ?", "Guy8").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man pool 2 man to man tie breaker finalist guy 9" do test "nine man pool 2 man to man tie breaker finalist guy 9" do
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
nineManBracketPoolTwoGuyNineHeadToHead nineManBracketPoolTwoGuyNineHeadToHead
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man pool 2 man to man tie breaker finalist guy 3" do test "nine man pool 2 man to man tie breaker finalist guy 3" do
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeHeadToHead nineManBracketPoolTwoGuyThreeHeadToHead
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals man to man tie breaker guy 3" do test "nine man conso finals man to man tie breaker guy 3" do
nineManBracketPoolTwoGuyNineHeadToHead nineManBracketPoolTwoGuyNineHeadToHead
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man conso finals man to man tie breaker guy 9" do test "nine man conso finals man to man tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeHeadToHead nineManBracketPoolTwoGuyThreeHeadToHead
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man pool 2 deductedPoints tie breaker finalist guy 3" do test "nine man pool 2 deductedPoints tie breaker finalist guy 3" do
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeDeductedPoints nineManBracketPoolTwoGuyThreeDeductedPoints
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals deductedPoints tie breaker guy 9" do test "nine man conso finals deductedPoints tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeDeductedPoints nineManBracketPoolTwoGuyThreeDeductedPoints
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
@@ -339,61 +339,61 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
test "nine man pool 2 mostDecisionPointsScored tie breaker finalist guy 3" do test "nine man pool 2 mostDecisionPointsScored tie breaker finalist guy 3" do
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeMostDecisionPoints nineManBracketPoolTwoGuyThreeMostDecisionPoints
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals mostDecisionPointsScored tie breaker guy 9" do test "nine man conso finals mostDecisionPointsScored tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeMostDecisionPoints nineManBracketPoolTwoGuyThreeMostDecisionPoints
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man pool 2 QuickestPin tie breaker finalist guy 3" do test "nine man pool 2 QuickestPin tie breaker finalist guy 3" do
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeQuickestPin nineManBracketPoolTwoGuyThreeQuickestPin
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals QuickestPin tie breaker guy 9" do test "nine man conso finals QuickestPin tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeQuickestPin nineManBracketPoolTwoGuyThreeQuickestPin
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man pool 2 teamPoints tie breaker finalist guy 3" do test "nine man pool 2 teamPoints tie breaker finalist guy 3" do
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeTeamPoints nineManBracketPoolTwoGuyThreeTeamPoints
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals teamPoints tie breaker guy 9" do test "nine man conso finals teamPoints tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeTeamPoints nineManBracketPoolTwoGuyThreeTeamPoints
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man pool 2 mostPins tie breaker finalist guy 3" do test "nine man pool 2 mostPins tie breaker finalist guy 3" do
wrestler = Wrestler.where("name = ?", "Guy3").first wrestler = Wrestler.where("name = ?", "Guy3").first
nineManBracketPoolTwoGuyThreeMostPins nineManBracketPoolTwoGuyThreeMostPins
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals mostPins tie breaker guy 9" do test "nine man conso finals mostPins tie breaker guy 9" do
nineManBracketPoolTwoGuyThreeMostPins nineManBracketPoolTwoGuyThreeMostPins
wrestler = Wrestler.where("name = ?", "Guy9").first wrestler = Wrestler.where("name = ?", "Guy9").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "nine man pool 1 mostTechs tie breaker finalist guy 8" do test "nine man pool 1 mostTechs tie breaker finalist guy 8" do
nineManBracketPoolOneGuyEightMostTechs nineManBracketPoolOneGuyEightMostTechs
wrestler = Wrestler.where("name = ?", "Guy8").first wrestler = Wrestler.where("name = ?", "Guy8").first
assert_equal 6000, wrestler.boutByRound(6) assert_equal 6000, wrestler.bout_by_round(6)
end end
test "nine man conso finals mostTechs tie breaker guy 10" do test "nine man conso finals mostTechs tie breaker guy 10" do
nineManBracketPoolOneGuyEightMostTechs nineManBracketPoolOneGuyEightMostTechs
wrestler = Wrestler.where("name = ?", "Guy10").first wrestler = Wrestler.where("name = ?", "Guy10").first
assert_equal 6001, wrestler.boutByRound(6) assert_equal 6001, wrestler.bout_by_round(6)
end end
test "twoPoolsToFinal total points finals" do test "twoPoolsToFinal total points finals" do
@@ -402,35 +402,35 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
wrestler2 = Wrestler.where("name = ?", "Guy3").first wrestler2 = Wrestler.where("name = ?", "Guy3").first
#Won four in pool #Won four in pool
assert_equal 22, wrestler1.totalTeamPoints assert_equal 22, wrestler1.total_team_points
#Won two in pool #Won two in pool
assert_equal 18, wrestler2.totalTeamPoints assert_equal 18, wrestler2.total_team_points
end end
test "advancement points 1/2" do test "advancement points 1/2" do
nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 12, wrestler1.placementPoints assert_equal 12, wrestler1.placement_points
end end
test "advancement points 3/4" do test "advancement points 3/4" do
nineManBracketPoolOneOutrightWinnerGuyTwo nineManBracketPoolOneOutrightWinnerGuyTwo
wrestler1 = Wrestler.where("name = ?", "Guy8").first wrestler1 = Wrestler.where("name = ?", "Guy8").first
assert_equal 9, wrestler1.placementPoints assert_equal 9, wrestler1.placement_points
end end
test "advancement points 5/6" do test "advancement points 5/6" do
elevenManBracketToFinals elevenManBracketToFinals
wrestler = Wrestler.where("name = ?", "Guy17").first wrestler = Wrestler.where("name = ?", "Guy17").first
assert_equal 6, wrestler.placementPoints assert_equal 6, wrestler.placement_points
end end
test "advancement points 7/8" do test "advancement points 7/8" do
elevenManBracketToFinals elevenManBracketToFinals
wrestler = Wrestler.where("name = ?", "Guy19").first wrestler = Wrestler.where("name = ?", "Guy19").first
assert_equal 3, wrestler.placementPoints assert_equal 3, wrestler.placement_points
end end
test "advancement points winner 1/2" do test "advancement points winner 1/2" do
@@ -438,7 +438,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
nineManBracketPoolTwoGuyThreeHeadToHead nineManBracketPoolTwoGuyThreeHeadToHead
endMatch(6000,"Guy2") endMatch(6000,"Guy2")
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 16, wrestler1.placementPoints assert_equal 16, wrestler1.placement_points
end end
test "advancement points winner 3/4" do test "advancement points winner 3/4" do
@@ -446,91 +446,91 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
nineManBracketPoolTwoGuyThreeHeadToHead nineManBracketPoolTwoGuyThreeHeadToHead
endMatch(6001,"Guy8") endMatch(6001,"Guy8")
wrestler1 = Wrestler.where("name = ?", "Guy8").first wrestler1 = Wrestler.where("name = ?", "Guy8").first
assert_equal 10, wrestler1.placementPoints assert_equal 10, wrestler1.placement_points
end end
test "advancement points winner 5/6" do test "advancement points winner 5/6" do
elevenManBracketFinished elevenManBracketFinished
wrestler = Wrestler.where("name = ?", "Guy17").first wrestler = Wrestler.where("name = ?", "Guy17").first
assert_equal 7, wrestler.placementPoints assert_equal 7, wrestler.placement_points
end end
test "advancement points winner 7/8" do test "advancement points winner 7/8" do
elevenManBracketFinished elevenManBracketFinished
wrestler = Wrestler.where("name = ?", "Guy19").first wrestler = Wrestler.where("name = ?", "Guy19").first
assert_equal 4, wrestler.placementPoints assert_equal 4, wrestler.placement_points
end end
test "bonus points major" do test "bonus points major" do
endMatchWithMajor(2002,"Guy2") endMatchWithMajor(2002,"Guy2")
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 5, wrestler1.teamPointsEarned assert_equal 5, wrestler1.team_points_earned
end end
test "bonus points pin" do test "bonus points pin" do
endMatchWithPin(2002,"Guy2") endMatchWithPin(2002,"Guy2")
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 6, wrestler1.teamPointsEarned assert_equal 6, wrestler1.team_points_earned
end end
test "bonus points tech fall" do test "bonus points tech fall" do
endMatchWithTech(2002,"Guy2") endMatchWithTech(2002,"Guy2")
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 5.5, wrestler1.teamPointsEarned assert_equal 5.5, wrestler1.team_points_earned
end end
test "pool team points win" do test "pool team points win" do
endMatch(2002,"Guy2") endMatch(2002,"Guy2")
wrestler1 = Wrestler.where("name = ?", "Guy2").first wrestler1 = Wrestler.where("name = ?", "Guy2").first
assert_equal 4, wrestler1.teamPointsEarned assert_equal 4, wrestler1.team_points_earned
end end
test "advancement points fourPoolsToQuarter Quarter" do test "advancement points fourPoolsToQuarter Quarter" do
elevenManBracketToQuarter elevenManBracketToQuarter
wrestler1 = Wrestler.where("name = ?", "Guy11").first wrestler1 = Wrestler.where("name = ?", "Guy11").first
assert_equal 3, wrestler1.placementPoints assert_equal 3, wrestler1.placement_points
end end
test "advancement points fourPoolsToQuarter Semis" do test "advancement points fourPoolsToQuarter Semis" do
elevenManBracketToSemis elevenManBracketToSemis
wrestler = Wrestler.where("name = ?", "Guy11").first wrestler = Wrestler.where("name = ?", "Guy11").first
assert_equal 9, wrestler.placementPoints assert_equal 9, wrestler.placement_points
end end
test "advancement points twoPoolsToSemi Semis" do test "advancement points twoPoolsToSemi Semis" do
sevenManTwoPoolToSemi sevenManTwoPoolToSemi
wrestler = Wrestler.where("name = ?", "Casey Davis").first wrestler = Wrestler.where("name = ?", "Casey Davis").first
assert_equal 9, wrestler.placementPoints assert_equal 9, wrestler.placement_points
end end
test "advancement points twoPoolsToSemi Finals" do test "advancement points twoPoolsToSemi Finals" do
sevenManTwoPoolSemiToFinals sevenManTwoPoolSemiToFinals
wrestler = Wrestler.where("name = ?", "Casey Davis").first wrestler = Wrestler.where("name = ?", "Casey Davis").first
assert_equal 12, wrestler.placementPoints assert_equal 12, wrestler.placement_points
end end
test "advancement points fourPoolsToSemi Semis and Conso Semis" do test "advancement points fourPoolsToSemi Semis and Conso Semis" do
sixteenManToSemi sixteenManToSemi
wrestler = Wrestler.where("name = ?", "Guy22").first wrestler = Wrestler.where("name = ?", "Guy22").first
assert_equal 9, wrestler.placementPoints assert_equal 9, wrestler.placement_points
wrestler = Wrestler.where("name = ?", "Guy29").first wrestler = Wrestler.where("name = ?", "Guy29").first
assert_equal 3, wrestler.placementPoints assert_equal 3, wrestler.placement_points
end end
test "extra does not score points but does get pool criteria" do test "extra does not score points but does get pool criteria" do
extraDoesNotScoreTeamPoints extraDoesNotScoreTeamPoints
wrestler = Wrestler.where("name = ?", "Guy22").first wrestler = Wrestler.where("name = ?", "Guy22").first
assert_equal 0, wrestler.totalTeamPoints assert_equal 0, wrestler.total_team_points
assert_equal 2, wrestler.teamPointsEarned assert_equal 2, wrestler.team_points_earned
end end
test "Test mat assignment when adding a mat and when destroying a mat" do test "Test mat assignment when adding a mat and when destroying a mat" do
@@ -547,21 +547,21 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
test "Championship bracket wins are 2pts" do test "Championship bracket wins are 2pts" do
elevenManBracketToQuarter elevenManBracketToQuarter
assert_equal 9, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned assert_equal 9, Wrestler.where("name = ?", "Guy11").first.team_points_earned
endMatch(4006,"Guy11") endMatch(4006,"Guy11")
assert_equal 17, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned assert_equal 17, Wrestler.where("name = ?", "Guy11").first.team_points_earned
endMatch(4007,"Guy14") endMatch(4007,"Guy14")
endMatch(5004,"Guy11") endMatch(5004,"Guy11")
assert_equal 22, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned assert_equal 22, Wrestler.where("name = ?", "Guy11").first.team_points_earned
end end
test "Conso bracket wins are 1pt" do test "Conso bracket wins are 1pt" do
elevenManBracketToSemis elevenManBracketToSemis
assert_equal 7, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned assert_equal 7, Wrestler.where("name = ?", "Guy17").first.team_points_earned
endMatch(5006,"Guy17") endMatch(5006,"Guy17")
assert_equal 11, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned assert_equal 11, Wrestler.where("name = ?", "Guy17").first.team_points_earned
end end
test "One pool placement points" do test "One pool placement points" do
@@ -570,16 +570,16 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
wrestler2 = Wrestler.where("name = ?", "Jaden Mattox").first wrestler2 = Wrestler.where("name = ?", "Jaden Mattox").first
wrestler3 = Wrestler.where("name = ?", "Jackson Lakso").first wrestler3 = Wrestler.where("name = ?", "Jackson Lakso").first
wrestler4 = Wrestler.where("name = ?", "JD Woods").first wrestler4 = Wrestler.where("name = ?", "JD Woods").first
assert_equal 16, wrestler1.placementPoints assert_equal 16, wrestler1.placement_points
assert_equal 12, wrestler2.placementPoints assert_equal 12, wrestler2.placement_points
assert_equal 10, wrestler3.placementPoints assert_equal 10, wrestler3.placement_points
assert_equal 9, wrestler4.placementPoints assert_equal 9, wrestler4.placement_points
end end
test "One pool placement points zero if pool not finished" do test "One pool placement points zero if pool not finished" do
singlePoolNotFinished singlePoolNotFinished
wrestler1 = Wrestler.where("name = ?", "James Wimer").first wrestler1 = Wrestler.where("name = ?", "James Wimer").first
assert_equal 0, wrestler1.placementPoints assert_equal 0, wrestler1.placement_points
end end

View File

@@ -74,9 +74,9 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
tournament.weights.each do |w| tournament.weights.each do |w|
w.wrestlers.each do |wr| w.wrestlers.each do |wr|
round = 1 round = 1
if w.totalRounds(matchups) > 5 if w.total_rounds(matchups) > 5
until round > w.poolRounds(matchups) do until round > w.pool_rounds(matchups) do
if wr.boutByRound(round) == "BYE" if wr.bout_by_round(round) == "BYE"
message = "BYE" message = "BYE"
end end
round += 1 round += 1
@@ -94,7 +94,7 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
test "tournament can be set to high school weight classes" do test "tournament can be set to high school weight classes" do
@tournament.weights.destroy_all @tournament.weights.destroy_all
@tournament.createCustomWeights("hs") @tournament.create_pre_defined_weights("hs")
assert_equal Weight::HS_WEIGHT_CLASSES.size, @tournament.weights.size assert_equal Weight::HS_WEIGHT_CLASSES.size, @tournament.weights.size
end end
@@ -251,7 +251,7 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
end end
test "finals matches in last round" do test "finals matches in last round" do
lastRound = @tournament.totalRounds lastRound = @tournament.total_rounds
finalsMatches = @tournament.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"} finalsMatches = @tournament.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| finalsMatches.each do |m|
assert_equal lastRound, m.round assert_equal lastRound, m.round

View File

@@ -11,17 +11,17 @@ class SwapWrestlersTest < ActionDispatch::IntegrationTest
wrestler2 = wrestlers(:swap_wrestlers_wrestler_2) wrestler2 = wrestlers(:swap_wrestlers_wrestler_2)
wrestler3 = wrestlers(:swap_wrestlers_wrestler_3) wrestler3 = wrestlers(:swap_wrestlers_wrestler_3)
wrestler4 = wrestlers(:swap_wrestlers_wrestler_4) wrestler4 = wrestlers(:swap_wrestlers_wrestler_4)
SwapWrestlers.new.swapWrestlers(wrestler1.id,wrestler2.id) SwapWrestlers.new.swap_wrestlers_bracket_lines(wrestler1.id,wrestler2.id)
#Variable needs refreshed otherwise asserts fail #Variable needs refreshed otherwise asserts fail
wrestler1 = Wrestler.find(54) wrestler1 = Wrestler.find(54)
wrestler2 = Wrestler.find(55) wrestler2 = Wrestler.find(55)
assert_not_empty wrestler1.matchAgainst(wrestler3) assert_not_empty wrestler1.match_against(wrestler3)
assert_equal 2, wrestler1.pool assert_equal 2, wrestler1.pool
assert_equal 2, wrestler1.bracket_line assert_equal 2, wrestler1.bracket_line
assert_not_empty wrestler2.matchAgainst(wrestler4) assert_not_empty wrestler2.match_against(wrestler4)
assert_equal 1, wrestler2.pool assert_equal 1, wrestler2.pool
assert_equal 1, wrestler2.bracket_line assert_equal 1, wrestler2.bracket_line
end end