mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-05-16 18:34:05 +00:00
Speeding up tests and renaming a few methods in generateMatchups
This commit is contained in:
@@ -8,7 +8,6 @@ module GeneratesTournamentMatches
|
||||
poolToBracket() if tournament_type == "Pool to bracket"
|
||||
self.curently_generating_matches = nil
|
||||
self.save
|
||||
matches
|
||||
end
|
||||
if Rails.env.production?
|
||||
handle_asynchronously :generateMatchups
|
||||
@@ -16,13 +15,11 @@ module GeneratesTournamentMatches
|
||||
|
||||
def poolToBracket
|
||||
destroyAllMatches
|
||||
buildTournamentWeights
|
||||
generateMatches
|
||||
# This is not working for pool order and I cannot get tests working
|
||||
movePoolSeedsToFinalPoolRound
|
||||
generatePoolToBracketMatches
|
||||
poolToBracketPostMatchCreation
|
||||
end
|
||||
|
||||
def buildTournamentWeights
|
||||
def generatePoolToBracketMatches
|
||||
weights.order(:max).each do |weight|
|
||||
Pool.new(weight).generatePools()
|
||||
last_match = matches.where(weight: weight).order(round: :desc).limit(1).first
|
||||
@@ -31,11 +28,12 @@ module GeneratesTournamentMatches
|
||||
end
|
||||
end
|
||||
|
||||
def generateMatches
|
||||
def poolToBracketPostMatchCreation
|
||||
moveFinalsMatchesToLastRound
|
||||
assignBouts
|
||||
assignLoserNames
|
||||
assignFirstMatchesToMats
|
||||
movePoolSeedsToFinalPoolRound
|
||||
end
|
||||
|
||||
def moveFinalsMatchesToLastRound
|
||||
|
||||
@@ -7,6 +7,10 @@ class Match < ActiveRecord::Base
|
||||
|
||||
|
||||
after_update do
|
||||
after_update_actions
|
||||
end
|
||||
|
||||
def after_update_actions
|
||||
if self.finished == 1 && self.winner_id != nil
|
||||
if self.w1 && self.w2
|
||||
wrestler1.touch
|
||||
|
||||
@@ -6,17 +6,14 @@ class Pool
|
||||
end
|
||||
|
||||
def generatePools
|
||||
matches = []
|
||||
pools = @weight.pools
|
||||
while @pool <= pools
|
||||
matches += roundRobin()
|
||||
roundRobin
|
||||
@pool += 1
|
||||
end
|
||||
return matches
|
||||
end
|
||||
|
||||
def roundRobin
|
||||
matches = []
|
||||
wrestlers = @weight.wrestlersForPool(@pool)
|
||||
poolMatches = RoundRobinTournament.schedule(wrestlers).reverse
|
||||
poolMatches.each_with_index do |b, index|
|
||||
@@ -24,16 +21,14 @@ class Pool
|
||||
bouts = b.map
|
||||
bouts.each do |bout|
|
||||
if bout[0] != nil and bout[1] != nil
|
||||
match = @tournament.matches.create(
|
||||
@tournament.matches.create(
|
||||
w1: bout[0].id,
|
||||
w2: bout[1].id,
|
||||
weight_id: @weight.id,
|
||||
bracket_position: "Pool",
|
||||
round: round)
|
||||
matches << match
|
||||
end
|
||||
end
|
||||
end
|
||||
matches
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ class Weight < ActiveRecord::Base
|
||||
end
|
||||
|
||||
before_save do
|
||||
self.tournament.destroyAllMatches
|
||||
# self.tournament.destroyAllMatches
|
||||
end
|
||||
|
||||
def wrestlersForPool(pool)
|
||||
|
||||
@@ -5,12 +5,12 @@ class MatchesControllerTest < ActionController::TestCase
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
@match = @tournament.matches.first
|
||||
# @tournament.generateMatchups
|
||||
@match = Match.where("tournament_id = ? and mat_id = ?",1,1).first
|
||||
end
|
||||
|
||||
def post_update
|
||||
patch :update, id: @match.id, match: {w1: @match.w1, w2: @match.w2}
|
||||
patch :update, id: @match.id, match: {tournament_id: 1, mat_id: 1}
|
||||
end
|
||||
|
||||
def get_edit
|
||||
|
||||
@@ -5,7 +5,7 @@ class MatsControllerTest < ActionController::TestCase
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
# @tournament.generateMatchups
|
||||
@mat = mats(:one)
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class SchoolsControllerTest < ActionController::TestCase
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
# @tournament.generateMatchups
|
||||
@school = @tournament.schools.first
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class StaticPagesControllerTest < ActionController::TestCase
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
# @tournament.generateMatchups
|
||||
@school = @tournament.schools.first
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ include Devise::TestHelpers
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
# @tournament.generateMatchups
|
||||
@school = @tournament.schools.first
|
||||
@wrestlers = @tournament.weights.first.wrestlers
|
||||
@adjust = Teampointadjust.find(1)
|
||||
|
||||
@@ -5,7 +5,7 @@ class WeightsControllerTest < ActionController::TestCase
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
# @tournament.generateMatchups
|
||||
@weight = @tournament.weights.first
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class WrestlersControllerTest < ActionController::TestCase
|
||||
|
||||
setup do
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
# @tournament.generateMatchups
|
||||
@school = @tournament.schools.first
|
||||
@wrestler = @school.wrestlers.first
|
||||
end
|
||||
|
||||
2035
test/fixtures/matches.yml
vendored
2035
test/fixtures/matches.yml
vendored
File diff suppressed because it is too large
Load Diff
660
test/fixtures/wrestlers.yml
vendored
660
test/fixtures/wrestlers.yml
vendored
@@ -1,24 +1,7 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
name: Zach Collins
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 4
|
||||
season_loss: 8
|
||||
season_win: 30
|
||||
criteria: DP 5th
|
||||
|
||||
two:
|
||||
name: Jaden Mattox
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 1
|
||||
season_loss: 3
|
||||
season_win: 49
|
||||
criteria: SP 2nd
|
||||
|
||||
three:
|
||||
wrestler1:
|
||||
id: 1
|
||||
name: Jackson Lakso
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
@@ -27,7 +10,8 @@ three:
|
||||
season_win: 30
|
||||
criteria: SQ
|
||||
|
||||
four:
|
||||
wrestler2:
|
||||
id: 2
|
||||
name: JD Woods
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
@@ -36,7 +20,28 @@ four:
|
||||
season_win: 30
|
||||
criteria: DP 6th
|
||||
|
||||
five:
|
||||
wrestler3:
|
||||
id: 3
|
||||
name: Jaden Mattox
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 1
|
||||
season_loss: 3
|
||||
season_win: 49
|
||||
criteria: SP 2nd
|
||||
|
||||
wrestler4:
|
||||
id: 4
|
||||
name: Zach Collins
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
original_seed: 4
|
||||
season_loss: 8
|
||||
season_win: 30
|
||||
criteria: DP 5th
|
||||
|
||||
wrestler5:
|
||||
id: 5
|
||||
name: James Wimer
|
||||
school_id: 1
|
||||
weight_id: 1
|
||||
@@ -45,7 +50,8 @@ five:
|
||||
season_win: 49
|
||||
criteria: SP 5th
|
||||
|
||||
six:
|
||||
wrestler6:
|
||||
id: 6
|
||||
name: Derek Wurzauf
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
@@ -54,7 +60,8 @@ six:
|
||||
season_win: 16
|
||||
criteria:
|
||||
|
||||
seven:
|
||||
wrestler7:
|
||||
id: 7
|
||||
name: Casey Davis
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
@@ -63,34 +70,8 @@ seven:
|
||||
season_win: 16
|
||||
criteria: DQ
|
||||
|
||||
eight:
|
||||
name: Ethan Leapley
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 4
|
||||
season_loss: 15
|
||||
season_win: 20
|
||||
criteria: DP 6th
|
||||
|
||||
nine:
|
||||
name: Clayton Ray
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 1
|
||||
season_loss: 4
|
||||
season_win: 30
|
||||
criteria: SP 7th
|
||||
|
||||
ten:
|
||||
name: Robbie Fusner
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 3
|
||||
season_loss: 5
|
||||
season_win: 40
|
||||
criteria: SQ
|
||||
|
||||
eleven:
|
||||
wrestler8:
|
||||
id: 8
|
||||
name: Kameron Teacher
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
@@ -99,7 +80,18 @@ eleven:
|
||||
season_win: 50
|
||||
criteria: SQ
|
||||
|
||||
twelve:
|
||||
wrestler9:
|
||||
id: 9
|
||||
name: Robbie Fusner
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 3
|
||||
season_loss: 5
|
||||
season_win: 40
|
||||
criteria: SQ
|
||||
|
||||
wrestler10:
|
||||
id: 10
|
||||
name: Guy1
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
@@ -108,7 +100,28 @@ twelve:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirteen:
|
||||
wrestler11:
|
||||
id: 11
|
||||
name: Ethan Leapley
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 4
|
||||
season_loss: 15
|
||||
season_win: 20
|
||||
criteria: DP 6th
|
||||
|
||||
wrestler12:
|
||||
id: 12
|
||||
name: Clayton Ray
|
||||
school_id: 1
|
||||
weight_id: 2
|
||||
original_seed: 1
|
||||
season_loss: 4
|
||||
season_win: 30
|
||||
criteria: SP 7th
|
||||
|
||||
wrestler13:
|
||||
id: 13
|
||||
name: Guy2
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
@@ -117,61 +130,8 @@ thirteen:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourteen:
|
||||
name: Guy3
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fifteen:
|
||||
name: Guy4
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
sixteen:
|
||||
name: Guy5
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
seventeen:
|
||||
name: Guy6
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
eighteen:
|
||||
name: Guy7
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
ninteen:
|
||||
name: Guy8
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twenty:
|
||||
wrestler14:
|
||||
id: 14
|
||||
name: Guy9
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
@@ -180,7 +140,48 @@ twenty:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentyone:
|
||||
wrestler15:
|
||||
id: 15
|
||||
name: Guy7
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler16:
|
||||
id: 16
|
||||
name: Guy3
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler17:
|
||||
id: 17
|
||||
name: Guy4
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler18:
|
||||
id: 18
|
||||
name: Guy8
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
original_seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler19:
|
||||
id: 19
|
||||
name: Guy10
|
||||
school_id: 1
|
||||
weight_id: 3
|
||||
@@ -189,88 +190,28 @@ twentyone:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentytwo:
|
||||
name: Guy11
|
||||
wrestler20:
|
||||
id: 20
|
||||
name: Guy6
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 1
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentythree:
|
||||
name: Guy12
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentyfour:
|
||||
name: Guy13
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentyfive:
|
||||
name: Guy14
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentysix:
|
||||
name: Guy15
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
weight_id: 3
|
||||
original_seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twnetyseven:
|
||||
name: Guy16
|
||||
wrestler21:
|
||||
id: 21
|
||||
name: Guy5
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 6
|
||||
weight_id: 3
|
||||
original_seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentyeight:
|
||||
name: Guy17
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
twentynine:
|
||||
name: Guy18
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 8
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirty:
|
||||
name: Guy19
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 9
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thrityone:
|
||||
wrestler22:
|
||||
id: 22
|
||||
name: Guy20
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
@@ -279,7 +220,48 @@ thrityone:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtytwo:
|
||||
wrestler23:
|
||||
id: 23
|
||||
name: Guy12
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler24:
|
||||
id: 24
|
||||
name: Guy16
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler25:
|
||||
id: 25
|
||||
name: Guy13
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler26:
|
||||
id: 26
|
||||
name: Guy15
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler27:
|
||||
id: 27
|
||||
name: Guy21
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
@@ -288,133 +270,58 @@ thirtytwo:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtythree:
|
||||
name: Guy22
|
||||
wrestler28:
|
||||
id: 28
|
||||
name: Guy11
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
weight_id: 4
|
||||
original_seed: 1
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtyfour:
|
||||
name: Guy23
|
||||
wrestler29:
|
||||
id: 29
|
||||
name: Guy14
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtyfive:
|
||||
name: Guy24
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtysix:
|
||||
name: Guy25
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
weight_id: 4
|
||||
original_seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtyseven:
|
||||
name: Guy26
|
||||
wrestler30:
|
||||
id: 30
|
||||
name: Guy18
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtyeight:
|
||||
name: Guy27
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
thirtynine:
|
||||
name: Guy28
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourty:
|
||||
name: Guy29
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
weight_id: 4
|
||||
original_seed: 8
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtyone:
|
||||
name: Guy30
|
||||
wrestler31:
|
||||
id: 31
|
||||
name: Guy17
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
weight_id: 4
|
||||
original_seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler32:
|
||||
id: 32
|
||||
name: Guy19
|
||||
school_id: 1
|
||||
weight_id: 4
|
||||
original_seed: 9
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtytwo:
|
||||
name: Guy31
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 10
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtythree:
|
||||
name: Guy32
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 11
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtyfour:
|
||||
name: Guy33
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 12
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtyfive:
|
||||
name: Guy34
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 13
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtysix:
|
||||
name: Guy35
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 14
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtyseven:
|
||||
wrestler33:
|
||||
id: 33
|
||||
name: Guy36
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
@@ -423,7 +330,118 @@ fourtyseven:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtyeight:
|
||||
wrestler34:
|
||||
id: 34
|
||||
name: Guy31
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 10
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler35:
|
||||
id: 35
|
||||
name: Guy22
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 1
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler36:
|
||||
id: 36
|
||||
name: Guy32
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 11
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler37:
|
||||
id: 37
|
||||
name: Guy23
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler38:
|
||||
id: 38
|
||||
name: Guy34
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 13
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler39:
|
||||
id: 39
|
||||
name: Guy29
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 8
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler40:
|
||||
id: 40
|
||||
name: Guy26
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 5
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler41:
|
||||
id: 41
|
||||
name: Guy35
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 14
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler42:
|
||||
id: 42
|
||||
name: Guy30
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 9
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler43:
|
||||
id: 43
|
||||
name: Guy27
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 6
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler44:
|
||||
id: 44
|
||||
name: Guy28
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
original_seed: 7
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler45:
|
||||
id: 45
|
||||
name: Guy37
|
||||
school_id: 1
|
||||
weight_id: 5
|
||||
@@ -432,43 +450,38 @@ fourtyeight:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtynine:
|
||||
name: Guy38
|
||||
wrestler46:
|
||||
id: 46
|
||||
name: Guy33
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed: 1
|
||||
weight_id: 5
|
||||
original_seed: 12
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fourtynine:
|
||||
name: Guy39
|
||||
wrestler47:
|
||||
id: 47
|
||||
name: Guy24
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed: 2
|
||||
weight_id: 5
|
||||
original_seed: 3
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fifty:
|
||||
name: Guy40
|
||||
wrestler48:
|
||||
id: 48
|
||||
name: Guy25
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
weight_id: 5
|
||||
original_seed: 4
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fiftyone:
|
||||
name: Guy41
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fiftytwo:
|
||||
wrestler49:
|
||||
id: 49
|
||||
name: Guy42
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
@@ -477,7 +490,28 @@ fiftytwo:
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
fiftythree:
|
||||
wrestler50:
|
||||
id: 50
|
||||
name: Guy39
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed: 2
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler51:
|
||||
id: 51
|
||||
name: Guy41
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler52:
|
||||
id: 52
|
||||
name: Guy43
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
@@ -485,3 +519,13 @@ fiftythree:
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
|
||||
wrestler53:
|
||||
id: 53
|
||||
name: Guy40
|
||||
school_id: 1
|
||||
weight_id: 6
|
||||
original_seed:
|
||||
season_loss: 2
|
||||
season_win: 50
|
||||
criteria:
|
||||
@@ -3,129 +3,127 @@ require 'test_helper'
|
||||
class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
|
||||
def setup
|
||||
@tournament = Tournament.find(1)
|
||||
@tournament.generateMatchups
|
||||
@matches = @tournament.matches
|
||||
tournament = Tournament.find(1)
|
||||
tournament.generateMatchups
|
||||
end
|
||||
|
||||
def showMatches
|
||||
matches = Weight.where("id = ?", 4).first.matches
|
||||
# matches = @matches.select{|m| m.weight_id == 4}
|
||||
matches.each do |m|
|
||||
puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}"
|
||||
end
|
||||
end
|
||||
# def showMatches
|
||||
# matches = Weight.where("id = ?", 4).first.matches
|
||||
# matches.each do |m|
|
||||
# puts "Bout: #{m.bout_number} #{m.w1_name} vs #{m.w2_name} #{m.bracket_position} #{m.poolNumber}"
|
||||
# end
|
||||
# end
|
||||
|
||||
def singlePoolNotFinished
|
||||
matches = @matches
|
||||
endMatch(1000,"Jackson Lakso",matches)
|
||||
endMatch(1001,"Jaden Mattox",matches)
|
||||
endMatch(2000,"James Wimer",matches)
|
||||
endMatch(2001,"Jaden Mattox",matches)
|
||||
endMatch(3000,"Jaden Mattox",matches)
|
||||
endMatch(3001,"James Wimer",matches)
|
||||
endMatch(4000,"JD Woods",matches)
|
||||
endMatch(4001,"James Wimer",matches)
|
||||
endMatch(5000,"James Wimer",matches)
|
||||
|
||||
endMatch(1000,"Jackson Lakso")
|
||||
endMatch(1001,"Jaden Mattox")
|
||||
endMatch(2000,"James Wimer")
|
||||
endMatch(2001,"Jaden Mattox")
|
||||
endMatch(3000,"Jaden Mattox")
|
||||
endMatch(3001,"James Wimer")
|
||||
endMatch(4000,"JD Woods")
|
||||
endMatch(4001,"James Wimer")
|
||||
endMatch(5000,"James Wimer")
|
||||
end
|
||||
|
||||
def singlePoolFinished
|
||||
singlePoolNotFinished
|
||||
matches = @matches
|
||||
endMatch(5001,"Jackson Lakso",matches)
|
||||
|
||||
endMatch(5001,"Jackson Lakso")
|
||||
end
|
||||
|
||||
def sixteenManToSemi
|
||||
matches = @matches
|
||||
endMatch(1013,"Guy22",matches)
|
||||
endMatch(1014,"Guy29",matches)
|
||||
endMatch(2012,"Guy29",matches)
|
||||
endMatch(2013,"Guy22",matches)
|
||||
endMatch(3012,"Guy37",matches)
|
||||
endMatch(3013,"Guy22",matches)
|
||||
endMatch(1015,"Guy36",matches)
|
||||
endMatch(1016,"Guy32",matches)
|
||||
endMatch(2014,"Guy36",matches)
|
||||
endMatch(2015,"Guy32",matches)
|
||||
endMatch(3014,"Guy36",matches)
|
||||
endMatch(3015,"Guy23",matches)
|
||||
endMatch(1017,"Guy31",matches)
|
||||
endMatch(1018,"Guy35",matches)
|
||||
endMatch(2016,"Guy35",matches)
|
||||
endMatch(2017,"Guy31",matches)
|
||||
endMatch(3016,"Guy27",matches)
|
||||
endMatch(3017,"Guy31",matches)
|
||||
endMatch(1019,"Guy34",matches)
|
||||
endMatch(1020,"Guy26",matches)
|
||||
endMatch(2018,"Guy30",matches)
|
||||
endMatch(2019,"Guy34",matches)
|
||||
endMatch(3018,"Guy26",matches)
|
||||
endMatch(3019,"Guy34",matches)
|
||||
|
||||
endMatch(1013,"Guy22")
|
||||
endMatch(1014,"Guy29")
|
||||
endMatch(2012,"Guy29")
|
||||
endMatch(2013,"Guy22")
|
||||
endMatch(3012,"Guy37")
|
||||
endMatch(3013,"Guy22")
|
||||
endMatch(1015,"Guy36")
|
||||
endMatch(1016,"Guy32")
|
||||
endMatch(2014,"Guy36")
|
||||
endMatch(2015,"Guy32")
|
||||
endMatch(3014,"Guy36")
|
||||
endMatch(3015,"Guy23")
|
||||
endMatch(1017,"Guy31")
|
||||
endMatch(1018,"Guy35")
|
||||
endMatch(2016,"Guy35")
|
||||
endMatch(2017,"Guy31")
|
||||
endMatch(3016,"Guy27")
|
||||
endMatch(3017,"Guy31")
|
||||
endMatch(1019,"Guy34")
|
||||
endMatch(1020,"Guy26")
|
||||
endMatch(2018,"Guy30")
|
||||
endMatch(2019,"Guy34")
|
||||
endMatch(3018,"Guy26")
|
||||
endMatch(3019,"Guy34")
|
||||
end
|
||||
|
||||
|
||||
def sevenManTwoPoolToSemi
|
||||
matches = @matches
|
||||
endMatch(1006,"Casey Davis",matches)
|
||||
endMatch(1007,"Ethan Leapley",matches)
|
||||
endMatch(2006,"Clayton Ray",matches)
|
||||
endMatch(2007,"Ethan Leapley",matches)
|
||||
endMatch(3006,"Ethan Leapley",matches)
|
||||
endMatch(3007,"Casey Davis",matches)
|
||||
endMatch(1008,"Kameron Teacher",matches)
|
||||
endMatch(2008,"Kameron Teacher",matches)
|
||||
endMatch(3008,"Robbie Fusner",matches)
|
||||
|
||||
endMatch(1006,"Casey Davis")
|
||||
endMatch(1007,"Ethan Leapley")
|
||||
endMatch(2006,"Clayton Ray")
|
||||
endMatch(2007,"Ethan Leapley")
|
||||
endMatch(3006,"Ethan Leapley")
|
||||
endMatch(3007,"Casey Davis")
|
||||
endMatch(1008,"Kameron Teacher")
|
||||
endMatch(2008,"Kameron Teacher")
|
||||
endMatch(3008,"Robbie Fusner")
|
||||
end
|
||||
|
||||
def sevenManTwoPoolSemiToFinals
|
||||
sevenManTwoPoolToSemi
|
||||
matches = @matches
|
||||
endMatch(4005,"Casey Davis",matches)
|
||||
endMatch(4004,"Ethan Leapley",matches)
|
||||
|
||||
endMatch(4005,"Casey Davis")
|
||||
endMatch(4004,"Ethan Leapley")
|
||||
end
|
||||
|
||||
def nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatch(1002,"Guy8",matches)
|
||||
endMatch(1003,"Guy5",matches)
|
||||
endMatch(2002,"Guy2",matches)
|
||||
endMatch(2003,"Guy8",matches)
|
||||
endMatch(3002,"Guy5",matches)
|
||||
endMatch(3003,"Guy2",matches)
|
||||
endMatch(4002,"Guy8",matches)
|
||||
endMatch(4003,"Guy2",matches)
|
||||
endMatch(5002,"Guy2",matches)
|
||||
endMatch(5003,"Guy10",matches)
|
||||
|
||||
endMatch(1002,"Guy8")
|
||||
endMatch(1003,"Guy5")
|
||||
endMatch(2002,"Guy2")
|
||||
endMatch(2003,"Guy8")
|
||||
endMatch(3002,"Guy5")
|
||||
endMatch(3003,"Guy2")
|
||||
endMatch(4002,"Guy8")
|
||||
endMatch(4003,"Guy2")
|
||||
endMatch(5002,"Guy2")
|
||||
endMatch(5003,"Guy10")
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyNineHeadToHead
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatch(1004,"Guy4",matches)
|
||||
endMatch(1005,"Guy3",matches)
|
||||
endMatch(2004,"Guy9",matches)
|
||||
endMatch(2005,"Guy7",matches)
|
||||
endMatch(3004,"Guy9",matches)
|
||||
endMatch(3005,"Guy3",matches)
|
||||
|
||||
endMatch(1004,"Guy4")
|
||||
endMatch(1005,"Guy3")
|
||||
endMatch(2004,"Guy9")
|
||||
endMatch(2005,"Guy7")
|
||||
endMatch(3004,"Guy9")
|
||||
endMatch(3005,"Guy3")
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeHeadToHead
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatch(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy3",matches)
|
||||
endMatch(2004,"Guy3",matches)
|
||||
endMatch(2005,"Guy7",matches)
|
||||
endMatch(3004,"Guy9",matches)
|
||||
endMatch(3005,"Guy4",matches)
|
||||
|
||||
endMatch(1004,"Guy9")
|
||||
endMatch(1005,"Guy3")
|
||||
endMatch(2004,"Guy3")
|
||||
endMatch(2005,"Guy7")
|
||||
endMatch(3004,"Guy9")
|
||||
endMatch(3005,"Guy4")
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeDeductedPoints
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatch(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy7",matches)
|
||||
endMatch(2004,"Guy3",matches)
|
||||
endMatch(2005,"Guy7",matches)
|
||||
endMatch(3004,"Guy9",matches)
|
||||
endMatch(3005,"Guy3",matches)
|
||||
|
||||
endMatch(1004,"Guy9")
|
||||
endMatch(1005,"Guy7")
|
||||
endMatch(2004,"Guy3")
|
||||
endMatch(2005,"Guy7")
|
||||
endMatch(3004,"Guy9")
|
||||
endMatch(3005,"Guy3")
|
||||
deduct = Teampointadjust.new
|
||||
deduct.wrestler_id = translateNameToId("Guy7")
|
||||
deduct.points = 1
|
||||
@@ -133,174 +131,161 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeMostDecisionPoints
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatchExtraPoints(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy7",matches)
|
||||
endMatchExtraPoints(2004,"Guy3",matches)
|
||||
endMatch(2005,"Guy7",matches)
|
||||
endMatch(3004,"Guy9",matches)
|
||||
endMatchExtraPoints(3005,"Guy3",matches)
|
||||
|
||||
endMatchExtraPoints(1004,"Guy9")
|
||||
endMatch(1005,"Guy7")
|
||||
endMatchExtraPoints(2004,"Guy3")
|
||||
endMatch(2005,"Guy7")
|
||||
endMatch(3004,"Guy9")
|
||||
endMatchExtraPoints(3005,"Guy3")
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeQuickestPin
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatchWithQuickPin(1004,"Guy9",matches)
|
||||
endMatchWithPin(1005,"Guy7",matches)
|
||||
endMatchWithQuickPin(2004,"Guy3",matches)
|
||||
endMatchWithPin(2005,"Guy7",matches)
|
||||
endMatchWithPin(3004,"Guy9",matches)
|
||||
endMatchWithQuickestPin(3005,"Guy3",matches)
|
||||
|
||||
endMatchWithQuickPin(1004,"Guy9")
|
||||
endMatchWithPin(1005,"Guy7")
|
||||
endMatchWithQuickPin(2004,"Guy3")
|
||||
endMatchWithPin(2005,"Guy7")
|
||||
endMatchWithPin(3004,"Guy9")
|
||||
endMatchWithQuickestPin(3005,"Guy3")
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeTeamPoints
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatch(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy7",matches)
|
||||
endMatchWithMajor(2004,"Guy3",matches)
|
||||
endMatch(2005,"Guy7",matches)
|
||||
endMatch(3004,"Guy9",matches)
|
||||
endMatch(3005,"Guy3",matches)
|
||||
|
||||
endMatch(1004,"Guy9")
|
||||
endMatch(1005,"Guy7")
|
||||
endMatchWithMajor(2004,"Guy3")
|
||||
endMatch(2005,"Guy7")
|
||||
endMatch(3004,"Guy9")
|
||||
endMatch(3005,"Guy3")
|
||||
end
|
||||
|
||||
def nineManBracketPoolTwoGuyThreeMostPins
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatchWithMajor(1004,"Guy9",matches)
|
||||
endMatch(1005,"Guy7",matches)
|
||||
endMatchWithPin(2004,"Guy3",matches)
|
||||
endMatchWithMajor(2005,"Guy7",matches)
|
||||
endMatch(3004,"Guy9",matches)
|
||||
endMatch(3005,"Guy3",matches)
|
||||
|
||||
endMatchWithMajor(1004,"Guy9")
|
||||
endMatch(1005,"Guy7")
|
||||
endMatchWithPin(2004,"Guy3")
|
||||
endMatchWithMajor(2005,"Guy7")
|
||||
endMatch(3004,"Guy9")
|
||||
endMatch(3005,"Guy3")
|
||||
end
|
||||
|
||||
def nineManBracketPoolOneGuyEightMostTechs
|
||||
matches = @matches.select{|m| m.weight_id == 3 && m.bracket_position == "Pool"}
|
||||
endMatchWithTech(1002,"Guy8",matches)
|
||||
endMatch(1003,"Guy5",matches)
|
||||
endMatchWithMajor(2002,"Guy2",matches)
|
||||
endMatchWithTech(2003,"Guy8",matches)
|
||||
endMatchWithMajor(3002,"Guy10",matches)
|
||||
endMatchWithMajor(3003,"Guy2",matches)
|
||||
endMatch(4002,"Guy8",matches)
|
||||
endMatchWithMajor(4003,"Guy10",matches)
|
||||
endMatchWithMajor(5002,"Guy2",matches)
|
||||
endMatchWithMajor(5003,"Guy10",matches)
|
||||
|
||||
endMatchWithTech(1002,"Guy8")
|
||||
endMatch(1003,"Guy5")
|
||||
endMatchWithMajor(2002,"Guy2")
|
||||
endMatchWithTech(2003,"Guy8")
|
||||
endMatchWithMajor(3002,"Guy10")
|
||||
endMatchWithMajor(3003,"Guy2")
|
||||
endMatch(4002,"Guy8")
|
||||
endMatchWithMajor(4003,"Guy10")
|
||||
endMatchWithMajor(5002,"Guy2")
|
||||
endMatchWithMajor(5003,"Guy10")
|
||||
end
|
||||
|
||||
def elevenManBracketToQuarter
|
||||
matches = @matches
|
||||
endMatch(1009,"Guy11",matches)
|
||||
endMatch(2009,"Guy11",matches)
|
||||
endMatch(3009,"Guy18",matches)
|
||||
endMatch(1010,"Guy12",matches)
|
||||
endMatch(2010,"Guy12",matches)
|
||||
endMatch(3010,"Guy17",matches)
|
||||
endMatch(1011,"Guy13",matches)
|
||||
endMatch(2011,"Guy13",matches)
|
||||
endMatch(3011,"Guy19",matches)
|
||||
endMatch(1012,"Guy14",matches)
|
||||
|
||||
endMatch(1009,"Guy11")
|
||||
endMatch(2009,"Guy11")
|
||||
endMatch(3009,"Guy18")
|
||||
endMatch(1010,"Guy12")
|
||||
endMatch(2010,"Guy12")
|
||||
endMatch(3010,"Guy17")
|
||||
endMatch(1011,"Guy13")
|
||||
endMatch(2011,"Guy13")
|
||||
endMatch(3011,"Guy19")
|
||||
endMatch(1012,"Guy14")
|
||||
end
|
||||
def elevenManBracketToSemis
|
||||
elevenManBracketToQuarter
|
||||
matches = @matches
|
||||
endMatch(4006,"Guy11",matches)
|
||||
endMatch(4007,"Guy14",matches)
|
||||
endMatch(4008,"Guy12",matches)
|
||||
endMatch(4009,"Guy13",matches)
|
||||
|
||||
endMatch(4006,"Guy11")
|
||||
endMatch(4007,"Guy14")
|
||||
endMatch(4008,"Guy12")
|
||||
endMatch(4009,"Guy13")
|
||||
end
|
||||
|
||||
def elevenManBracketToFinals
|
||||
elevenManBracketToSemis
|
||||
matches = @matches
|
||||
endMatch(5004,"Guy11",matches)
|
||||
endMatch(5005,"Guy12",matches)
|
||||
endMatch(5006,"Guy17",matches)
|
||||
endMatch(5007,"Guy18",matches)
|
||||
|
||||
endMatch(5004,"Guy11")
|
||||
endMatch(5005,"Guy12")
|
||||
endMatch(5006,"Guy17")
|
||||
endMatch(5007,"Guy18")
|
||||
end
|
||||
|
||||
def elevenManBracketFinished
|
||||
elevenManBracketToFinals
|
||||
matches = @matches
|
||||
endMatch(6004,"Guy11",matches)
|
||||
endMatch(6005,"Guy14",matches)
|
||||
endMatch(6006,"Guy17",matches)
|
||||
endMatch(6007,"Guy19",matches)
|
||||
|
||||
endMatch(6004,"Guy11")
|
||||
endMatch(6005,"Guy14")
|
||||
endMatch(6006,"Guy17")
|
||||
endMatch(6007,"Guy19")
|
||||
end
|
||||
|
||||
def extraDoesNotScoreTeamPoints
|
||||
matches = @matches
|
||||
|
||||
wrestlerName = "Guy22"
|
||||
wrestler = Wrestler.find(translateNameToId(wrestlerName))
|
||||
wrestler.extra = true
|
||||
wrestler.save
|
||||
endMatch(1013,"Guy22",matches)
|
||||
endMatch(1013,"Guy22")
|
||||
end
|
||||
|
||||
def endMatch(bout,winner,matches)
|
||||
def endMatch(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
# match = @matches.select{|m| m.bout_number == bout}.first
|
||||
match.win_type = "Decision"
|
||||
match.score = 1-0
|
||||
|
||||
match.save
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def endMatchExtraPoints(bout,winner,matches)
|
||||
def endMatchExtraPoints(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Decision"
|
||||
match.score = 0-2
|
||||
|
||||
match.save
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def endMatchWithMajor(bout,winner,matches)
|
||||
def endMatchWithMajor(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Major"
|
||||
match.score = 8-0
|
||||
|
||||
match.save
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def endMatchWithTech(bout,winner,matches)
|
||||
def endMatchWithTech(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Tech Fall"
|
||||
|
||||
match.save
|
||||
match.score = 15-0
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def endMatchWithPin(bout,winner,matches)
|
||||
def endMatchWithPin(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Pin"
|
||||
match.score = "5:00"
|
||||
|
||||
match.save
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def endMatchWithQuickestPin(bout,winner,matches)
|
||||
def endMatchWithQuickestPin(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Pin"
|
||||
match.score = "0:20"
|
||||
|
||||
match.save
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def endMatchWithQuickPin(bout,winner,matches)
|
||||
def endMatchWithQuickPin(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.win_type = "Pin"
|
||||
match.score = "1:20"
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def saveMatch(match,winner)
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.save
|
||||
end
|
||||
|
||||
@@ -458,7 +443,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
test "advancement points winner 1/2" do
|
||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
||||
endMatch(6000,"Guy2",@matches)
|
||||
endMatch(6000,"Guy2")
|
||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||
assert_equal 16, wrestler1.placementPoints
|
||||
end
|
||||
@@ -466,7 +451,7 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
test "advancement points winner 3/4" do
|
||||
nineManBracketPoolOneOutrightWinnerGuyTwo
|
||||
nineManBracketPoolTwoGuyThreeHeadToHead
|
||||
endMatch(6001,"Guy8",@matches)
|
||||
endMatch(6001,"Guy8")
|
||||
wrestler1 = Wrestler.where("name = ?", "Guy8").first
|
||||
assert_equal 10, wrestler1.placementPoints
|
||||
end
|
||||
@@ -486,25 +471,25 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "bonus points major" do
|
||||
endMatchWithMajor(2002,"Guy2",@matches)
|
||||
endMatchWithMajor(2002,"Guy2")
|
||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||
assert_equal 3, wrestler1.teamPointsEarned
|
||||
end
|
||||
|
||||
test "bonus points pin" do
|
||||
endMatchWithPin(2002,"Guy2",@matches)
|
||||
endMatchWithPin(2002,"Guy2")
|
||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||
assert_equal 4, wrestler1.teamPointsEarned
|
||||
end
|
||||
|
||||
test "bonus points tech fall" do
|
||||
endMatchWithTech(2002,"Guy2",@matches)
|
||||
endMatchWithTech(2002,"Guy2")
|
||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||
assert_equal 3.5, wrestler1.teamPointsEarned
|
||||
end
|
||||
|
||||
test "pool team points win" do
|
||||
endMatch(2002,"Guy2",@matches)
|
||||
endMatch(2002,"Guy2")
|
||||
wrestler1 = Wrestler.where("name = ?", "Guy2").first
|
||||
assert_equal 2, wrestler1.teamPointsEarned
|
||||
end
|
||||
@@ -570,19 +555,19 @@ class PoolAdvancementTest < ActionDispatch::IntegrationTest
|
||||
test "Championship bracket wins are 2pts" do
|
||||
elevenManBracketToQuarter
|
||||
assert_equal 7, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned
|
||||
matches = @matches
|
||||
endMatch(4006,"Guy11",matches)
|
||||
|
||||
endMatch(4006,"Guy11")
|
||||
assert_equal 15, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned
|
||||
endMatch(4007,"Guy14",matches)
|
||||
endMatch(5004,"Guy11",matches)
|
||||
endMatch(4007,"Guy14")
|
||||
endMatch(5004,"Guy11")
|
||||
assert_equal 20, Wrestler.where("name = ?", "Guy11").first.teamPointsEarned
|
||||
end
|
||||
|
||||
test "Conso bracket wins are 1pt" do
|
||||
elevenManBracketToSemis
|
||||
assert_equal 5, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned
|
||||
matches = @matches
|
||||
endMatch(5006,"Guy17",matches)
|
||||
|
||||
endMatch(5006,"Guy17")
|
||||
assert_equal 9, Wrestler.where("name = ?", "Guy17").first.teamPointsEarned
|
||||
end
|
||||
|
||||
|
||||
@@ -1,8 +1,60 @@
|
||||
require 'test_helper'
|
||||
|
||||
class SingleTestTest < ActionDispatch::IntegrationTest
|
||||
def setup
|
||||
@tournament = Tournament.find(1)
|
||||
# @tournament.generateMatchups
|
||||
# @matches = @tournament.matches
|
||||
end
|
||||
|
||||
#rake test test/integration/single_test_test.rb > matches.txt
|
||||
# Loser names need to be in quotes in yml file
|
||||
def showMatches
|
||||
# matches = Weight.where("id = ?", 4).first.matches
|
||||
count = 1
|
||||
|
||||
# Yml for matches
|
||||
# Match.where(tournament_id: 1).each do |m|
|
||||
# puts "tournament_1_bout_#{m.bout_number}:"
|
||||
# puts " tournament_id: #{m.tournament_id}"
|
||||
# puts " weight_id: #{m.weight_id}"
|
||||
# puts " bout_number: #{m.bout_number}"
|
||||
# puts " w1: #{m.w1}"
|
||||
# puts " w2: #{m.w2}"
|
||||
# puts " bracket_position: #{m.bracket_position}"
|
||||
# puts " bracket_position_number: #{m.bracket_position_number}"
|
||||
# puts " loser1_name: #{m.loser1_name}"
|
||||
# puts " loser2_name: #{m.loser2_name}"
|
||||
# puts " round: #{m.round}"
|
||||
# puts " mat_id: #{m.mat_id}"
|
||||
# puts " finished: #{m.finished}"
|
||||
# puts " w1_stat: "
|
||||
# puts " w2_stat: "
|
||||
# puts " score: "
|
||||
# puts " winner_id: "
|
||||
# puts " win_type: "
|
||||
# puts ""
|
||||
# count += 1
|
||||
# end
|
||||
|
||||
# Yml for wrestlers
|
||||
# @tournament.wrestlers.each do |w|
|
||||
# puts "tournament_1_#{w.name}:"
|
||||
# puts " id: #{count}"
|
||||
# puts " name: #{w.name}"
|
||||
# puts " school_id: #{w.school_id}"
|
||||
# puts " weight_id: #{w.weight_id}"
|
||||
# puts " original_seed: #{w.original_seed}"
|
||||
# puts " season_loss: #{w.season_loss}"
|
||||
# puts " season_win: #{w.season_win}"
|
||||
# puts " criteria: #{w.criteria}"
|
||||
# puts ""
|
||||
# count += 1
|
||||
# end
|
||||
end
|
||||
|
||||
test "the truth" do
|
||||
showMatches
|
||||
assert true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class TournamentTest < ActiveSupport::TestCase
|
||||
|
||||
test "the truth" do
|
||||
assert true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user