1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-06 14:36:59 +00:00

Added job_owner and 'description' to delayed_job to show on the tournament show page

This commit is contained in:
2019-11-26 23:40:01 -05:00
parent 2f4ea5e42f
commit 661c56d04e
7 changed files with 91 additions and 39 deletions

View File

@@ -5,17 +5,24 @@ class AdvanceWrestler
end
def advance
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
if Rails.env.production?
self.delay(:job_owner_id => @tournament.id, :job_owner_type => "Advance wrestler #{@wrestler.name} in the bracket").advance_raw
else
advance_raw
end
end
if Rails.env.production?
handle_asynchronously :advance
def advance_raw
pool_to_bracket_advancement if @tournament.tournament_type == "Pool to bracket"
end
def pool_to_bracket_advancement
if @wrestler.weight.all_pool_matches_finished(@wrestler.pool) and (@wrestler.finished_bracket_matches.size == 0 or @wrestler.weight.pools == 1)
PoolOrder.new(@wrestler.weight.wrestlers_in_pool(@wrestler.pool)).getPoolOrder
end
PoolAdvance.new(@wrestler,@wrestler.last_match).advanceWrestler
if @wrestler.weight.all_pool_matches_finished(@wrestler.pool)
PoolAdvance.new(@wrestler,@wrestler.last_match).advanceWrestler
end
end
end

View File

@@ -4,28 +4,38 @@ class GenerateTournamentMatches
end
def generateWeight(weight)
WipeTournamentMatches.new(@tournament).wipeWeightMatches(weight)
@tournament.curently_generating_matches = 1
@tournament.save
unAssignBouts
unAssignMats
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatchesWeight(weight) if @tournament.tournament_type == "Pool to bracket"
postMatchCreationActions
PoolToBracketGenerateLoserNames.new(@tournament).assignLoserNamesWeight(weight) if @tournament.tournament_type == "Pool to bracket"
if Rails.env.production?
self.delay(:job_owner_id => @tournament.id, :job_owner_type => "Generate matches for weights class #{weight.max}").generate_weight_raw(weight)
else
self.generate_weight_raw(weight)
end
end
if Rails.env.production?
handle_asynchronously :generateWeight
def generate_weight_raw(weight)
WipeTournamentMatches.new(@tournament).wipeWeightMatches(weight)
@tournament.curently_generating_matches = 1
@tournament.save
unAssignBouts
unAssignMats
PoolToBracketMatchGeneration.new(@tournament).generatePoolToBracketMatchesWeight(weight) if @tournament.tournament_type == "Pool to bracket"
postMatchCreationActions
PoolToBracketGenerateLoserNames.new(@tournament).assignLoserNamesWeight(weight) if @tournament.tournament_type == "Pool to bracket"
end
def generate
if Rails.env.production?
self.delay(:job_owner_id => @tournament.id, :job_owner_type => "Generate matches for all weights").generate_raw
else
self.generate_raw
end
end
def generate_raw
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
if Rails.env.production?
handle_asynchronously :generate
end
def standardStartingActions
@tournament.curently_generating_matches = 1

View File

@@ -7,6 +7,14 @@ class WrestlingdevImporter
end
def import
if Rails.env.production?
self.delay(:job_owner_id => @tournament.id, :job_owner_type => "Importing a backup").import_raw
else
import_raw
end
end
def import_raw
@tournament.curently_generating_matches = 1
@tournament.save
destroy_all
@@ -14,9 +22,6 @@ class WrestlingdevImporter
@tournament.curently_generating_matches = nil
@tournament.save
end
if Rails.env.production?
handle_asynchronously :import
end
def destroy_all
@tournament.mats.reload.each do | mat |