mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-02 13:15:27 +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)
|
||||
|
||||
Reference in New Issue
Block a user