mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Speeding up tests and renaming generateMatchup methods
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
1010
test/fixtures/wrestlers.yml
vendored
1010
test/fixtures/wrestlers.yml
vendored
File diff suppressed because it is too large
Load Diff
@@ -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,175 +131,162 @@ 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)
|
||||
match = Match.where(bout_number: bout).first
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
def endMatch(bout,winner)
|
||||
match = Match.where(bout_number: bout).first
|
||||
# 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"
|
||||
|
||||
match.save
|
||||
saveMatch(match,winner)
|
||||
end
|
||||
|
||||
def saveMatch(match,winner)
|
||||
match.finished = 1
|
||||
match.winner_id = translateNameToId(winner)
|
||||
match.save
|
||||
end
|
||||
|
||||
def translateNameToId(wrestler)
|
||||
@@ -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