mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
O
Merge branch 'development' of https://github.com/jcwimer/wrestlingApp into development
This commit is contained in:
@@ -163,7 +163,7 @@ class TournamentsController < ApplicationController
|
||||
end
|
||||
|
||||
def generate_matches
|
||||
@tournament.generateMatchups
|
||||
GenerateTournamentMatches.new(@tournament).generate
|
||||
end
|
||||
|
||||
def brackets
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
module GeneratesTournamentMatches
|
||||
|
||||
def generateMatchups
|
||||
self.curently_generating_matches = 1
|
||||
self.save
|
||||
resetSchoolScores
|
||||
setSeedsAndRandomSeedingWrestlersWithoutSeeds
|
||||
poolToBracket() if tournament_type == "Pool to bracket"
|
||||
self.curently_generating_matches = nil
|
||||
self.save
|
||||
end
|
||||
if Rails.env.production?
|
||||
handle_asynchronously :generateMatchups
|
||||
end
|
||||
|
||||
def poolToBracket
|
||||
destroyAllMatches
|
||||
generatePoolToBracketMatches
|
||||
poolToBracketPostMatchCreation
|
||||
end
|
||||
|
||||
def generatePoolToBracketMatches
|
||||
weights.order(:max).each do |weight|
|
||||
Pool.new(weight).generatePools()
|
||||
last_match = matches.where(weight: weight).order(round: :desc).limit(1).first
|
||||
highest_round = last_match.round
|
||||
PoolBracket.new(weight, highest_round).generateBracketMatches()
|
||||
end
|
||||
end
|
||||
|
||||
def poolToBracketPostMatchCreation
|
||||
moveFinalsMatchesToLastRound
|
||||
assignBouts
|
||||
assignLoserNames
|
||||
assignFirstMatchesToMats
|
||||
movePoolSeedsToFinalPoolRound
|
||||
end
|
||||
|
||||
def moveFinalsMatchesToLastRound
|
||||
finalsRound = self.totalRounds
|
||||
finalsMatches = self.matches.select{|m| m.bracket_position == "1/2" || m.bracket_position == "3/4" || m.bracket_position == "5/6" || m.bracket_position == "7/8"}
|
||||
finalsMatches. each do |m|
|
||||
m.round = finalsRound
|
||||
m.save
|
||||
end
|
||||
end
|
||||
|
||||
def setSeedsAndRandomSeedingWrestlersWithoutSeeds
|
||||
weights.each do |w|
|
||||
w.setSeeds
|
||||
end
|
||||
end
|
||||
|
||||
def movePoolSeedsToFinalPoolRound
|
||||
self.weights.each do |w|
|
||||
w.setOriginalSeedsToWrestleLastPoolRound
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,7 +1,5 @@
|
||||
class Tournament < ActiveRecord::Base
|
||||
|
||||
include GeneratesLoserNames
|
||||
include GeneratesTournamentMatches
|
||||
belongs_to :user
|
||||
has_many :schools, dependent: :destroy
|
||||
has_many :weights, dependent: :destroy
|
||||
@@ -24,10 +22,6 @@ class Tournament < ActiveRecord::Base
|
||||
time
|
||||
end
|
||||
|
||||
def resetSchoolScores
|
||||
schools.update_all("score = 0.0")
|
||||
end
|
||||
|
||||
def tournament_types
|
||||
["Pool to bracket"]
|
||||
end
|
||||
@@ -50,19 +44,6 @@ class Tournament < ActiveRecord::Base
|
||||
def matchesByRound(round)
|
||||
matches.joins(:weight).where(round: round).order("weights.max")
|
||||
end
|
||||
|
||||
def assignBouts
|
||||
bout_counts = Hash.new(0)
|
||||
matches.each do |m|
|
||||
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
||||
bout_counts[m.round] += 1
|
||||
m.save!
|
||||
end
|
||||
end
|
||||
|
||||
def assignFirstMatchesToMats
|
||||
assignMats(mats)
|
||||
end
|
||||
|
||||
def totalRounds
|
||||
self.matches.sort_by{|m| m.round}.last.round
|
||||
|
||||
@@ -46,22 +46,6 @@ class Weight < ActiveRecord::Base
|
||||
wrestlersForPool(pool).sort_by{|w| [w.original_seed ? 0 : 1, w.original_seed || 0]}
|
||||
end
|
||||
|
||||
def setOriginalSeedsToWrestleLastPoolRound
|
||||
pool = 1
|
||||
until pool > self.pools
|
||||
wrestler1 = poolSeedOrder(pool).first
|
||||
wrestler2 = poolSeedOrder(pool).second
|
||||
match = wrestler1.poolMatches.sort_by{|m| m.round}.last
|
||||
if match.w1 != wrestler2.id or match.w2 != wrestler2.id
|
||||
if match.w1 == wrestler1.id
|
||||
swapWrestlers(match.w2,wrestler2.id)
|
||||
elsif match.w2 == wrestler1.id
|
||||
swapWrestlers(match.w1,wrestler2.id)
|
||||
end
|
||||
end
|
||||
pool += 1
|
||||
end
|
||||
end
|
||||
|
||||
def swapWrestlers(wrestler1_id,wrestler2_id)
|
||||
SwapWrestlers.new.swapWrestlers(wrestler1_id,wrestler2_id)
|
||||
@@ -180,38 +164,5 @@ class Weight < ActiveRecord::Base
|
||||
def poolOrder(pool)
|
||||
PoolOrder.new(wrestlersForPool(pool)).getPoolOrder
|
||||
end
|
||||
|
||||
def randomSeeding
|
||||
wrestlerWithSeeds = self.wrestlers.select{|w| w.original_seed != nil }.sort_by{|w| w.original_seed}
|
||||
if wrestlerWithSeeds.size > 0
|
||||
highestSeed = wrestlerWithSeeds.last.seed
|
||||
seed = highestSeed + 1
|
||||
else
|
||||
seed = 1
|
||||
end
|
||||
wrestlersWithoutSeed = self.wrestlers.select{|w| w.original_seed == nil }
|
||||
wrestlersWithoutSeed.shuffle.each do |w|
|
||||
w.seed = seed
|
||||
w.save
|
||||
seed += 1
|
||||
end
|
||||
end
|
||||
|
||||
def setSeeds
|
||||
resetAllSeeds
|
||||
wrestlerWithSeeds = self.wrestlers.select{|w| w.original_seed != nil }
|
||||
wrestlerWithSeeds.each do |w|
|
||||
w.seed = w.original_seed
|
||||
w.save
|
||||
end
|
||||
randomSeeding
|
||||
end
|
||||
|
||||
def resetAllSeeds
|
||||
self.wrestlers.each do |w|
|
||||
w.seed = nil
|
||||
w.save
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -109,21 +109,26 @@ class PoolOrder
|
||||
end
|
||||
|
||||
def fastestPin
|
||||
timeArray = []
|
||||
wrestlersWithSamePoints.each do |w|
|
||||
timeArray << w.fastestPin
|
||||
wrestlersWithSamePointsWithPins = []
|
||||
wrestlersWithSamePoints.each do |wr|
|
||||
if wr.pinWins.size > 0
|
||||
wrestlersWithSamePointsWithPins << wr
|
||||
end
|
||||
end
|
||||
fastest = timeArray.max
|
||||
wrestlersWithFastestPin = wrestlersWithSamePoints.select{|w| w.fastestPin == fastest}
|
||||
addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
|
||||
wrestlersWithFastestPin.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
secondFastest = timeArray.sort[-2]
|
||||
wrestlersWithSecondFastestPin = wrestlersWithSamePoints.select{|w| w.fastestPin == secondFastest}
|
||||
addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first)
|
||||
wrestlersWithSecondFastestPin.each do |wr|
|
||||
addPoints(wr)
|
||||
if wrestlersWithSamePointsWithPins.size > 0
|
||||
fastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastestPin.pinTime}.first.fastestPin
|
||||
secondFastest = wrestlersWithSamePointsWithPins.sort_by{|w| w.fastestPin.pinTime}.second.fastestPin
|
||||
wrestlersWithFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastestPin.pinTime == fastest.pinTime}
|
||||
addPointsToWrestlersAhead(wrestlersWithFastestPin.first)
|
||||
wrestlersWithFastestPin.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
|
||||
wrestlersWithSecondFastestPin = wrestlersWithSamePointsWithPins.select{|w| w.fastestPin.pinTime == secondFastest.pinTime}
|
||||
addPointsToWrestlersAhead(wrestlersWithSecondFastestPin.first)
|
||||
wrestlersWithSecondFastestPin.each do |wr|
|
||||
addPoints(wr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
class GenerateTournamentMatches
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
end
|
||||
|
||||
def generate
|
||||
standardStartingActions
|
||||
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatches if @tournament.tournament_type == "Pool to bracket"
|
||||
postMatchCreationActions
|
||||
PoolToBracketMatchGeneration.new(@tournament).assignLoserNames if @tournament.tournament_type == "Pool to bracket"
|
||||
end
|
||||
|
||||
def standardStartingActions
|
||||
@tournament.curently_generating_matches = 1
|
||||
@tournament.save
|
||||
WipeTournamentMatches.new(@tournament).setUpMatchGeneration
|
||||
TournamentSeeding.new(@tournament).setSeeds
|
||||
end
|
||||
|
||||
def postMatchCreationActions
|
||||
moveFinalsMatchesToLastRound
|
||||
assignBouts
|
||||
assignFirstMatchesToMats
|
||||
@tournament.curently_generating_matches = nil
|
||||
@tournament.save
|
||||
end
|
||||
|
||||
def assignBouts
|
||||
bout_counts = Hash.new(0)
|
||||
@tournament.matches.each do |m|
|
||||
m.bout_number = m.round * 1000 + bout_counts[m.round]
|
||||
bout_counts[m.round] += 1
|
||||
m.save!
|
||||
end
|
||||
end
|
||||
|
||||
def moveFinalsMatchesToLastRound
|
||||
finalsRound = @tournament.totalRounds
|
||||
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|
|
||||
m.round = finalsRound
|
||||
m.save
|
||||
end
|
||||
end
|
||||
|
||||
def assignFirstMatchesToMats
|
||||
matsToAssign = @tournament.mats
|
||||
if matsToAssign.count > 0
|
||||
until matsToAssign.sort_by{|m| m.id}.last.matches.count == 4
|
||||
matsToAssign.sort_by{|m| m.id}.each do |m|
|
||||
m.assignNextMatch
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class PoolBracket
|
||||
class PoolBracketGeneration
|
||||
|
||||
def initialize(weight, highest_round)
|
||||
@weight = weight
|
||||
@@ -1,4 +1,4 @@
|
||||
class Pool
|
||||
class PoolGeneration
|
||||
def initialize(weight)
|
||||
@weight = weight
|
||||
@tournament = @weight.tournament
|
||||
@@ -1,8 +1,12 @@
|
||||
module GeneratesLoserNames
|
||||
def assignLoserNames
|
||||
class PoolToBracketGenerateLoserNames
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
end
|
||||
|
||||
def assignLoserNames
|
||||
matches_by_weight = nil
|
||||
weights.each do |w|
|
||||
matches_by_weight = matches.where(weight_id: w.id)
|
||||
@tournament.weights.each do |w|
|
||||
matches_by_weight = @tournament.matches.where(weight_id: w.id)
|
||||
if w.pool_bracket_type == "twoPoolsToSemi"
|
||||
twoPoolsToSemiLoser(matches_by_weight)
|
||||
elsif w.pool_bracket_type == "fourPoolsToQuarter"
|
||||
@@ -12,7 +16,7 @@ module GeneratesLoserNames
|
||||
end
|
||||
saveMatches(matches_by_weight)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def twoPoolsToSemiLoser(matches_by_weight)
|
||||
match1 = matches_by_weight.select{|m| m.loser1_name == "Winner Pool 1"}.first
|
||||
@@ -59,5 +63,6 @@ module GeneratesLoserNames
|
||||
matches.each do |m|
|
||||
m.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,46 @@
|
||||
class PoolToBracketMatchGeneration
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
end
|
||||
|
||||
|
||||
|
||||
def generatePoolToBracketMatches
|
||||
@tournament.weights.order(:max).each do |weight|
|
||||
PoolGeneration.new(weight).generatePools()
|
||||
last_match = @tournament.matches.where(weight: weight).order(round: :desc).limit(1).first
|
||||
highest_round = last_match.round
|
||||
PoolBracketGeneration.new(weight, highest_round).generateBracketMatches()
|
||||
end
|
||||
movePoolSeedsToFinalPoolRound
|
||||
end
|
||||
|
||||
def movePoolSeedsToFinalPoolRound
|
||||
@tournament.weights.each do |w|
|
||||
setOriginalSeedsToWrestleLastPoolRound(w)
|
||||
end
|
||||
end
|
||||
|
||||
def setOriginalSeedsToWrestleLastPoolRound(weight)
|
||||
pool = 1
|
||||
until pool > weight.pools
|
||||
wrestler1 = weight.poolSeedOrder(pool).first
|
||||
wrestler2 = weight.poolSeedOrder(pool).second
|
||||
match = wrestler1.poolMatches.sort_by{|m| m.round}.last
|
||||
if match.w1 != wrestler2.id or match.w2 != wrestler2.id
|
||||
if match.w1 == wrestler1.id
|
||||
SwapWrestlers.new.swapWrestlers(match.w2,wrestler2.id)
|
||||
elsif match.w2 == wrestler1.id
|
||||
SwapWrestlers.new.swapWrestlers(match.w1,wrestler2.id)
|
||||
end
|
||||
end
|
||||
pool += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def assignLoserNames
|
||||
PoolToBracketGenerateLoserNames.new(@tournament).assignLoserNames
|
||||
end
|
||||
|
||||
end
|
||||
44
app/services/tournament_services/tournament_seeding.rb
Normal file
44
app/services/tournament_services/tournament_seeding.rb
Normal file
@@ -0,0 +1,44 @@
|
||||
class TournamentSeeding
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
end
|
||||
|
||||
def setSeeds
|
||||
@tournament.weights.each do |w|
|
||||
resetAllSeeds(w)
|
||||
setOriginalSeeds(w)
|
||||
randomSeeding(w)
|
||||
end
|
||||
end
|
||||
|
||||
def randomSeeding(weight)
|
||||
wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }.sort_by{|w| w.original_seed}
|
||||
if wrestlerWithSeeds.size > 0
|
||||
highestSeed = wrestlerWithSeeds.last.seed
|
||||
seed = highestSeed + 1
|
||||
else
|
||||
seed = 1
|
||||
end
|
||||
wrestlersWithoutSeed = weight.wrestlers.select{|w| w.original_seed == nil }
|
||||
wrestlersWithoutSeed.shuffle.each do |w|
|
||||
w.seed = seed
|
||||
w.save
|
||||
seed += 1
|
||||
end
|
||||
end
|
||||
|
||||
def setOriginalSeeds(weight)
|
||||
wrestlerWithSeeds = weight.wrestlers.select{|w| w.original_seed != nil }
|
||||
wrestlerWithSeeds.each do |w|
|
||||
w.seed = w.original_seed
|
||||
w.save
|
||||
end
|
||||
end
|
||||
|
||||
def resetAllSeeds(weight)
|
||||
weight.wrestlers.each do |w|
|
||||
w.seed = nil
|
||||
w.save
|
||||
end
|
||||
end
|
||||
end
|
||||
19
app/services/tournament_services/wipe_tournament_matches.rb
Normal file
19
app/services/tournament_services/wipe_tournament_matches.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
class WipeTournamentMatches
|
||||
|
||||
def initialize( tournament )
|
||||
@tournament = tournament
|
||||
end
|
||||
|
||||
def setUpMatchGeneration
|
||||
wipeMatches
|
||||
resetSchoolScores
|
||||
end
|
||||
|
||||
def wipeMatches
|
||||
@tournament.matches.destroy_all
|
||||
end
|
||||
|
||||
def resetSchoolScores
|
||||
@tournament.schools.update_all("score = 0.0")
|
||||
end
|
||||
end
|
||||
@@ -34,6 +34,10 @@ module Wrestling
|
||||
config.to_prepare do
|
||||
DeviseController.respond_to :html, :json
|
||||
end
|
||||
|
||||
config.autoload_paths += %W(#{config.root}/app/services/tournament_services)
|
||||
config.autoload_paths += %W(#{config.root}/app/services/wrestler_services)
|
||||
config.autoload_paths += %W(#{config.root}/app/services/bracket_advancement)
|
||||
end
|
||||
|
||||
|
||||
|
||||
3282
test/fixtures/matches.yml
vendored
3282
test/fixtures/matches.yml
vendored
File diff suppressed because it is too large
Load Diff
214
test/fixtures/wrestlers.yml
vendored
214
test/fixtures/wrestlers.yml
vendored
@@ -1,531 +1,637 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
wrestler1:
|
||||
tournament_1_wrestler_1:
|
||||
id: 1
|
||||
name: Jackson Lakso
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 3
|
||||
seed: 2
|
||||
season_loss: 8
|
||||
season_win: 30
|
||||
criteria: SQ
|
||||
extra:
|
||||
|
||||
wrestler2:
|
||||
tournament_1_wrestler_2:
|
||||
id: 2
|
||||
name: JD Woods
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 5
|
||||
seed: 5
|
||||
season_loss: 12
|
||||
season_win: 30
|
||||
criteria: DP 6th
|
||||
extra:
|
||||
|
||||
wrestler3:
|
||||
tournament_1_wrestler_3:
|
||||
id: 3
|
||||
name: Jaden Mattox
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 1
|
||||
seed: 1
|
||||
season_loss: 3
|
||||
season_win: 49
|
||||
criteria: SP 2nd
|
||||
extra:
|
||||
|
||||
wrestler4:
|
||||
tournament_1_wrestler_4:
|
||||
id: 4
|
||||
name: Zach Collins
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 4
|
||||
seed: 4
|
||||
season_loss: 8
|
||||
season_win: 30
|
||||
criteria: DP 5th
|
||||
extra:
|
||||
|
||||
wrestler5:
|
||||
tournament_1_wrestler_5:
|
||||
id: 5
|
||||
name: James Wimer
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 2
|
||||
seed: 3
|
||||
season_loss: 12
|
||||
season_win: 49
|
||||
criteria: SP 5th
|
||||
extra:
|
||||
|
||||
wrestler6:
|
||||
tournament_1_wrestler_6:
|
||||
id: 6
|
||||
name: Derek Wurzauf
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 6
|
||||
seed: 3
|
||||
season_loss: 15
|
||||
season_win: 16
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler7:
|
||||
tournament_1_wrestler_7:
|
||||
id: 7
|
||||
name: Casey Davis
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 5
|
||||
seed: 5
|
||||
season_loss: 15
|
||||
season_win: 16
|
||||
criteria: DQ
|
||||
extra:
|
||||
|
||||
wrestler8:
|
||||
tournament_1_wrestler_8:
|
||||
id: 8
|
||||
name: Kameron Teacher
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 2
|
||||
seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria: SQ
|
||||
extra:
|
||||
|
||||
wrestler9:
|
||||
tournament_1_wrestler_9:
|
||||
id: 9
|
||||
name: Robbie Fusner
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 3
|
||||
seed: 6
|
||||
season_loss: 5
|
||||
season_win: 40
|
||||
criteria: SQ
|
||||
extra:
|
||||
|
||||
wrestler10:
|
||||
tournament_1_wrestler_10:
|
||||
id: 10
|
||||
name: Guy1
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 7
|
||||
seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler11:
|
||||
tournament_1_wrestler_11:
|
||||
id: 11
|
||||
name: Ethan Leapley
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 4
|
||||
seed: 7
|
||||
season_loss: 15
|
||||
season_win: 20
|
||||
criteria: DP 6th
|
||||
extra:
|
||||
|
||||
wrestler12:
|
||||
tournament_1_wrestler_12:
|
||||
id: 12
|
||||
name: Clayton Ray
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 1
|
||||
seed: 1
|
||||
season_loss: 4
|
||||
season_win: 30
|
||||
criteria: SP 7th
|
||||
extra:
|
||||
|
||||
wrestler13:
|
||||
tournament_1_wrestler_13:
|
||||
id: 13
|
||||
name: Guy2
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 1
|
||||
seed: 1
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler14:
|
||||
tournament_1_wrestler_14:
|
||||
id: 14
|
||||
name: Guy9
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 8
|
||||
seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler15:
|
||||
tournament_1_wrestler_15:
|
||||
id: 15
|
||||
name: Guy7
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 6
|
||||
seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler16:
|
||||
tournament_1_wrestler_16:
|
||||
id: 16
|
||||
name: Guy3
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 2
|
||||
seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler17:
|
||||
tournament_1_wrestler_17:
|
||||
id: 17
|
||||
name: Guy4
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 3
|
||||
seed: 8
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler18:
|
||||
tournament_1_wrestler_18:
|
||||
id: 18
|
||||
name: Guy8
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 7
|
||||
seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler19:
|
||||
tournament_1_wrestler_19:
|
||||
id: 19
|
||||
name: Guy10
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 9
|
||||
seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler20:
|
||||
tournament_1_wrestler_20:
|
||||
id: 20
|
||||
name: Guy6
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 5
|
||||
seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler21:
|
||||
tournament_1_wrestler_21:
|
||||
id: 21
|
||||
name: Guy5
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 4
|
||||
seed: 9
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler22:
|
||||
tournament_1_wrestler_22:
|
||||
id: 22
|
||||
name: Guy20
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 10
|
||||
seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler23:
|
||||
tournament_1_wrestler_23:
|
||||
id: 23
|
||||
name: Guy12
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 2
|
||||
seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler24:
|
||||
tournament_1_wrestler_24:
|
||||
id: 24
|
||||
name: Guy16
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 6
|
||||
seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler25:
|
||||
tournament_1_wrestler_25:
|
||||
id: 25
|
||||
name: Guy13
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 3
|
||||
seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler26:
|
||||
tournament_1_wrestler_26:
|
||||
id: 26
|
||||
name: Guy15
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 5
|
||||
seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler27:
|
||||
tournament_1_wrestler_27:
|
||||
id: 27
|
||||
name: Guy21
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 11
|
||||
seed: 8
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler28:
|
||||
tournament_1_wrestler_28:
|
||||
id: 28
|
||||
name: Guy11
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 1
|
||||
seed: 1
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler29:
|
||||
tournament_1_wrestler_29:
|
||||
id: 29
|
||||
name: Guy14
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 4
|
||||
seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler30:
|
||||
tournament_1_wrestler_30:
|
||||
id: 30
|
||||
name: Guy18
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 8
|
||||
seed: 11
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler31:
|
||||
tournament_1_wrestler_31:
|
||||
id: 31
|
||||
name: Guy17
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 7
|
||||
seed: 10
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler32:
|
||||
tournament_1_wrestler_32:
|
||||
id: 32
|
||||
name: Guy19
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 9
|
||||
seed: 9
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler33:
|
||||
tournament_1_wrestler_33:
|
||||
id: 33
|
||||
name: Guy36
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 15
|
||||
seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler34:
|
||||
tournament_1_wrestler_34:
|
||||
id: 34
|
||||
name: Guy31
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 10
|
||||
seed: 10
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler35:
|
||||
tournament_1_wrestler_35:
|
||||
id: 35
|
||||
name: Guy22
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 1
|
||||
seed: 1
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler36:
|
||||
tournament_1_wrestler_36:
|
||||
id: 36
|
||||
name: Guy32
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 11
|
||||
seed: 11
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler37:
|
||||
tournament_1_wrestler_37:
|
||||
id: 37
|
||||
name: Guy23
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 2
|
||||
seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler38:
|
||||
tournament_1_wrestler_38:
|
||||
id: 38
|
||||
name: Guy34
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 13
|
||||
seed: 13
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler39:
|
||||
tournament_1_wrestler_39:
|
||||
id: 39
|
||||
name: Guy29
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 8
|
||||
seed: 16
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler40:
|
||||
tournament_1_wrestler_40:
|
||||
id: 40
|
||||
name: Guy26
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 5
|
||||
seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler41:
|
||||
tournament_1_wrestler_41:
|
||||
id: 41
|
||||
name: Guy35
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 14
|
||||
seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler42:
|
||||
tournament_1_wrestler_42:
|
||||
id: 42
|
||||
name: Guy30
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 9
|
||||
seed: 9
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler43:
|
||||
tournament_1_wrestler_43:
|
||||
id: 43
|
||||
name: Guy27
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 6
|
||||
seed: 14
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler44:
|
||||
tournament_1_wrestler_44:
|
||||
id: 44
|
||||
name: Guy28
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 7
|
||||
seed: 15
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler45:
|
||||
tournament_1_wrestler_45:
|
||||
id: 45
|
||||
name: Guy37
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 16
|
||||
seed: 8
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler46:
|
||||
tournament_1_wrestler_46:
|
||||
id: 46
|
||||
name: Guy33
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 12
|
||||
seed: 12
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler47:
|
||||
tournament_1_wrestler_47:
|
||||
id: 47
|
||||
name: Guy24
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 3
|
||||
seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler48:
|
||||
tournament_1_wrestler_48:
|
||||
id: 48
|
||||
name: Guy25
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 4
|
||||
seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler49:
|
||||
tournament_1_wrestler_49:
|
||||
id: 49
|
||||
name: Guy42
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler50:
|
||||
tournament_1_wrestler_50:
|
||||
id: 50
|
||||
name: Guy39
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed: 2
|
||||
seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler51:
|
||||
tournament_1_wrestler_51:
|
||||
id: 51
|
||||
name: Guy41
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler52:
|
||||
tournament_1_wrestler_52:
|
||||
id: 52
|
||||
name: Guy43
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
extra:
|
||||
|
||||
wrestler53:
|
||||
tournament_1_wrestler_53:
|
||||
id: 53
|
||||
name: Guy40
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
criteria:
|
||||
extra:
|
||||
@@ -4,10 +4,6 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
|
||||
def setup
|
||||
tournament = Tournament.find(1)
|
||||
|
||||
# WHY DOES THIS NOT WORK WITHOUT GENERATING MATCHUPS BEFORE EVERY TEST?
|
||||
# FIXTURES FOR MATCHES ARE FILLED OUT AND WORK FOR OTHER TESTS
|
||||
tournament.generateMatchups
|
||||
end
|
||||
|
||||
def singlePoolNotFinished
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'test_helper'
|
||||
class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
GenerateTournamentMatches.new(@tournament).generate
|
||||
end
|
||||
|
||||
def createTournament(numberOfWrestlers)
|
||||
@@ -69,7 +69,7 @@ class PoolbracketMatchupsTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
def checkForByeInPool(tournament)
|
||||
tournament.generateMatchups
|
||||
GenerateTournamentMatches.new(tournament).generate
|
||||
matchups = tournament.matches
|
||||
tournament.weights.each do |w|
|
||||
w.wrestlers.each do |wr|
|
||||
|
||||
@@ -36,7 +36,8 @@ class SingleTestTest < ActionDispatch::IntegrationTest
|
||||
|
||||
# Yml for wrestlers
|
||||
# @tournament.wrestlers.each do |w|
|
||||
# puts "tournament_1_#{w.name}:"
|
||||
# puts "tournament_1_wrestler_#{count}:"
|
||||
# puts " id: #{count}"
|
||||
# puts " name: #{w.name}"
|
||||
# puts " school_id: #{w.school_id}"
|
||||
# puts " weight_id: #{w.weight_id}"
|
||||
@@ -45,6 +46,7 @@ class SingleTestTest < ActionDispatch::IntegrationTest
|
||||
# puts " season_loss: #{w.season_loss}"
|
||||
# puts " season_win: #{w.season_win}"
|
||||
# puts " criteria: #{w.criteria}"
|
||||
# puts " extra: #{w.extra}"
|
||||
# puts ""
|
||||
# count += 1
|
||||
# end
|
||||
|
||||
Reference in New Issue
Block a user