mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-24 17:04:43 +00:00
Made the all results page grouping better and fixed the advance wrestler job.
This commit is contained in:
@@ -9,6 +9,11 @@ class AdvanceWrestlerJob < ApplicationJob
|
|||||||
end
|
end
|
||||||
|
|
||||||
def perform(wrestler, match)
|
def perform(wrestler, match)
|
||||||
|
# Add a small delay to increase chance of transaction commit
|
||||||
|
# without this some matches were getting a deserialization error when running the rake task
|
||||||
|
# to finish tournaments
|
||||||
|
sleep(0.5)
|
||||||
|
|
||||||
# Get tournament from wrestler
|
# Get tournament from wrestler
|
||||||
tournament = wrestler.tournament
|
tournament = wrestler.tournament
|
||||||
|
|
||||||
@@ -18,7 +23,7 @@ class AdvanceWrestlerJob < ApplicationJob
|
|||||||
tournament: tournament,
|
tournament: tournament,
|
||||||
job_name: job_name,
|
job_name: job_name,
|
||||||
status: "Running",
|
status: "Running",
|
||||||
details: "Match ID: #{match&.bout_number || 'No match'}"
|
details: "Match ID: #{match&.bout_number || 'No match'} Wrestler Name #{wrestler&.name || 'No Wrestler'}"
|
||||||
)
|
)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
<p id="alert" class="alert alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><%= alert %></p>
|
<p id="alert" class="alert alert-danger alert-dismissible"><a href="#" class="close" data-dismiss="alert" aria-label="close">×</a><%= alert %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div id="view" style="overflow-x: auto; overflow-y: hidden;"> <%# Horizontal scroll only %>
|
<div id="view" style="overflow-x: auto; overflow-y: hidden;"> <%# Horizontal scroll only %>
|
||||||
|
<br><br>
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<% @matches.select{|m| m.finished == 1 && m.w1 && m.w2}.sort_by{|m| [ m.bout_number, m.bracket_position, m.weight.max ]}.each do |match| %>
|
<% @matches.select{|m| m.finished == 1 && m.w1 && m.w2}.sort_by{|m| [ m.round, -m.bracket_position, m.weight.max ]}.each do |match| %>
|
||||||
<% if @round != match.round || @bracket_position != match.bracket_position %>
|
<% if @round != match.round || @bracket_position != match.bracket_position %>
|
||||||
<p><strong><%= match.bracket_position %> Round: <%= match.round %></strong></p>
|
<p><strong><%= match.bracket_position %> Round: <%= match.round %></strong></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<br><br>
|
|
||||||
<h3>
|
<h3>
|
||||||
<%= @tournament.name %> Info
|
<%= @tournament.name %> Info
|
||||||
</h3>
|
</h3>
|
||||||
|
|||||||
@@ -210,5 +210,10 @@ data:
|
|||||||
sync_binlog=1 # Flush binary logs after each transaction for safety
|
sync_binlog=1 # Flush binary logs after each transaction for safety
|
||||||
read_only=0 # Default, will be managed by the init script
|
read_only=0 # Default, will be managed by the init script
|
||||||
expire_logs_days=7 # Retain binary logs for 7 days
|
expire_logs_days=7 # Retain binary logs for 7 days
|
||||||
|
|
||||||
|
# if you want to ignore dbs to replicate
|
||||||
|
# replicate-ignore-db=wrestlingtourney-queue
|
||||||
|
# if you only want to replicate certain dbs
|
||||||
|
replicate-do-db=wrestlingtourney
|
||||||
|
|
||||||
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf
|
# /etc/mysql/mariadb.conf.d/70-mysettings.cnf
|
||||||
|
|||||||
@@ -5,33 +5,46 @@ namespace :tournament do
|
|||||||
|
|
||||||
@tournament = Tournament.find(204)
|
@tournament = Tournament.find(204)
|
||||||
|
|
||||||
Mat.create(
|
Mat.find_or_create_by(
|
||||||
name: "1",
|
name: "1",
|
||||||
tournament_id: @tournament.id
|
tournament_id: @tournament.id
|
||||||
)
|
)
|
||||||
Mat.create(
|
Mat.find_or_create_by(
|
||||||
name: "2",
|
name: "2",
|
||||||
tournament_id: @tournament.id
|
tournament_id: @tournament.id
|
||||||
)
|
)
|
||||||
Mat.create(
|
Mat.find_or_create_by(
|
||||||
name: "3",
|
name: "3",
|
||||||
tournament_id: @tournament.id
|
tournament_id: @tournament.id
|
||||||
)
|
)
|
||||||
Mat.create(
|
Mat.find_or_create_by(
|
||||||
name: "4",
|
name: "4",
|
||||||
tournament_id: @tournament.id
|
tournament_id: @tournament.id
|
||||||
)
|
)
|
||||||
Mat.create(
|
Mat.find_or_create_by(
|
||||||
name: "5",
|
name: "5",
|
||||||
tournament_id: @tournament.id
|
tournament_id: @tournament.id
|
||||||
)
|
)
|
||||||
|
|
||||||
GenerateTournamentMatches.new(@tournament).generate
|
GenerateTournamentMatches.new(@tournament).generate
|
||||||
sleep(180)
|
sleep(10)
|
||||||
|
while @tournament.reload.curently_generating_matches == 1
|
||||||
|
puts "Waiting for tournament to finish generating matches..."
|
||||||
|
sleep(5)
|
||||||
|
end
|
||||||
|
|
||||||
|
@tournament.reload # Ensure matches association is fresh before iterating
|
||||||
@tournament.matches.sort_by(&:bout_number).each do |match|
|
@tournament.matches.sort_by(&:bout_number).each do |match|
|
||||||
match.reload
|
match.reload
|
||||||
if match.loser1_name != "BYE" and match.loser2_name != "BYE"
|
if match.loser1_name != "BYE" and match.loser2_name != "BYE"
|
||||||
|
# Wait until both wrestlers are assigned
|
||||||
|
while match.w1.nil? || match.w2.nil?
|
||||||
|
puts "Waiting for wrestlers in match #{match.bout_number}..."
|
||||||
|
sleep(5) # Wait for 5 seconds before checking again
|
||||||
|
match.reload
|
||||||
|
end
|
||||||
|
puts "Finishing match with bout number #{match.bout_number}..."
|
||||||
|
|
||||||
# Choose a random winner
|
# Choose a random winner
|
||||||
wrestlers = [match.w1, match.w2]
|
wrestlers = [match.w1, match.w2]
|
||||||
match.winner_id = wrestlers.sample
|
match.winner_id = wrestlers.sample
|
||||||
@@ -63,10 +76,7 @@ namespace :tournament do
|
|||||||
|
|
||||||
# Mark match as finished
|
# Mark match as finished
|
||||||
match.finished = 1
|
match.finished = 1
|
||||||
match.save
|
match.save!
|
||||||
|
|
||||||
# Pause to simulate processing delay
|
|
||||||
sleep(10)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user