From 940f7b1d00c177bdbe585c695b1ddac77149bb95 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Fri, 16 Jan 2026 18:21:17 -0500 Subject: [PATCH] Job concurrency per tournament is 1 so we don't have to scale too much on active queue. Pages no longer refresh automatically after navigating away from the bout board. Tournament backups are no longer deleted when restoring from a backup. Cloudflare is blocking manual backup imports so I have deleted that form on the backups page. --- README.md | 2 +- app/jobs/advance_wrestler_job.rb | 6 ++++-- app/jobs/calculate_school_score_job.rb | 3 ++- app/jobs/generate_tournament_matches_job.rb | 3 ++- app/jobs/tournament_backup_job.rb | 3 ++- app/jobs/wrestlingdev_import_job.rb | 3 ++- .../bracket_advancement/advance_wrestler.rb | 4 ++-- .../wrestlingdev_importer.rb | 1 - app/views/tournament_backups/index.html.erb | 9 --------- app/views/tournaments/up_matches.html.erb | 18 +++++++++++++++++- 10 files changed, 32 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index ccde307..7b1c40b 100644 --- a/README.md +++ b/README.md @@ -149,7 +149,7 @@ SolidQueue plugin enabled in Puma ``` I have deployed Mission Control as a UI for SolidQueue. The uri for mission control is `/jobs`. -For the development environment, the user/password is dev/secret. For the production environment, it is defined by environment variables. +For the development environment, the user/password is dev/secret. For the production environment, it is defined by environment variables WRESTLINGDEV_MISSION_CONTROL_USER/WRESTLINGDEV_MISSION_CONTROL_PASSWORD. You can see this in `config/environments/production.rb` and `config/environments/development.rb`. ## Environment Variables diff --git a/app/jobs/advance_wrestler_job.rb b/app/jobs/advance_wrestler_job.rb index e73d590..1ebcf95 100644 --- a/app/jobs/advance_wrestler_job.rb +++ b/app/jobs/advance_wrestler_job.rb @@ -1,7 +1,9 @@ class AdvanceWrestlerJob < ApplicationJob queue_as :default + # associations are not available here so we had to pass tournament_id when creating the job + limits_concurrency to: 1, key: ->(_wrestler, _match, tournament_id) { "tournament:#{tournament_id}" } - def perform(wrestler, match) + def perform(wrestler, match, tournament_id) # Get tournament from wrestler tournament = wrestler.tournament @@ -29,4 +31,4 @@ class AdvanceWrestlerJob < ApplicationJob raise e end end -end \ No newline at end of file +end diff --git a/app/jobs/calculate_school_score_job.rb b/app/jobs/calculate_school_score_job.rb index b8c40b4..e6ba678 100644 --- a/app/jobs/calculate_school_score_job.rb +++ b/app/jobs/calculate_school_score_job.rb @@ -1,5 +1,6 @@ class CalculateSchoolScoreJob < ApplicationJob queue_as :default + limits_concurrency to: 1, key: ->(school) { "tournament:#{school.tournament_id}" } # Need for TournamentJobStatusIntegrationTest def self.perform_sync(school) @@ -35,4 +36,4 @@ class CalculateSchoolScoreJob < ApplicationJob raise e end end -end \ No newline at end of file +end diff --git a/app/jobs/generate_tournament_matches_job.rb b/app/jobs/generate_tournament_matches_job.rb index ccc4faa..25317ec 100644 --- a/app/jobs/generate_tournament_matches_job.rb +++ b/app/jobs/generate_tournament_matches_job.rb @@ -1,5 +1,6 @@ class GenerateTournamentMatchesJob < ApplicationJob queue_as :default + limits_concurrency to: 1, key: ->(tournament) { "tournament:#{tournament.id}" } def perform(tournament) # Log information about the job @@ -17,4 +18,4 @@ class GenerateTournamentMatchesJob < ApplicationJob raise # Re-raise the error so it's properly recorded end end -end \ No newline at end of file +end diff --git a/app/jobs/tournament_backup_job.rb b/app/jobs/tournament_backup_job.rb index fd2d380..b5d57cb 100644 --- a/app/jobs/tournament_backup_job.rb +++ b/app/jobs/tournament_backup_job.rb @@ -1,5 +1,6 @@ class TournamentBackupJob < ApplicationJob queue_as :default + limits_concurrency to: 1, key: ->(tournament) { "tournament:#{tournament.id}" } def perform(tournament, reason = nil) # Log information about the job @@ -29,4 +30,4 @@ class TournamentBackupJob < ApplicationJob raise e end end -end \ No newline at end of file +end diff --git a/app/jobs/wrestlingdev_import_job.rb b/app/jobs/wrestlingdev_import_job.rb index fa24507..62f15e2 100644 --- a/app/jobs/wrestlingdev_import_job.rb +++ b/app/jobs/wrestlingdev_import_job.rb @@ -1,5 +1,6 @@ class WrestlingdevImportJob < ApplicationJob queue_as :default + limits_concurrency to: 1, key: ->(tournament) { "tournament:#{tournament.id}" } def perform(tournament, import_data = nil) # Log information about the job @@ -30,4 +31,4 @@ class WrestlingdevImportJob < ApplicationJob raise e end end -end \ No newline at end of file +end diff --git a/app/services/bracket_advancement/advance_wrestler.rb b/app/services/bracket_advancement/advance_wrestler.rb index d2587a1..8c0eacb 100644 --- a/app/services/bracket_advancement/advance_wrestler.rb +++ b/app/services/bracket_advancement/advance_wrestler.rb @@ -8,7 +8,7 @@ class AdvanceWrestler def advance # Use perform_later which will execute based on centralized adapter config # This will be converted to inline execution in test environment by ActiveJob - AdvanceWrestlerJob.perform_later(@wrestler, @last_match) + AdvanceWrestlerJob.perform_later(@wrestler, @last_match, @tournament.id) end def advance_raw @@ -29,4 +29,4 @@ class AdvanceWrestler PoolAdvance.new(@wrestler).advanceWrestler end -end \ No newline at end of file +end diff --git a/app/services/tournament_services/wrestlingdev_importer.rb b/app/services/tournament_services/wrestlingdev_importer.rb index 91d4caf..fa7fade 100644 --- a/app/services/tournament_services/wrestlingdev_importer.rb +++ b/app/services/tournament_services/wrestlingdev_importer.rb @@ -41,7 +41,6 @@ class WrestlingdevImporter @tournament.matches.destroy_all @tournament.mat_assignment_rules.destroy_all # Explicitly destroy rules (might be redundant if Mat cascades) @tournament.delegates.destroy_all - @tournament.tournament_backups.destroy_all @tournament.tournament_job_statuses.destroy_all # Note: Teampointadjusts are deleted via School/Wrestler cascade end diff --git a/app/views/tournament_backups/index.html.erb b/app/views/tournament_backups/index.html.erb index 1b496f8..11dd808 100644 --- a/app/views/tournament_backups/index.html.erb +++ b/app/views/tournament_backups/index.html.erb @@ -27,12 +27,3 @@ and will also delete all of your current data. It's best to use the create backu

-

Import Manual Backup

-

Paste the backup text here. Note, if this is formatted wrong, you'll need to restore a backup from above to fix it and you'll see an error in your background jobs.

-<%= form_for(:tournament, url: import_manual_tournament_tournament_backups_path(@tournament)) do |f| %> -
- <%= f.label 'Import text' %>
- <%= f.text_area :import_text, cols: "30", rows: "20" %> -
- <%= submit_tag "Import", class: "btn btn-success", data: { turbo_confirm: 'Are you sure? This will delete everything for the current tournament and restore it with the backup text pasted below.' } %> -<% end %> diff --git a/app/views/tournaments/up_matches.html.erb b/app/views/tournaments/up_matches.html.erb index dd6bdac..a82c725 100644 --- a/app/views/tournaments/up_matches.html.erb +++ b/app/views/tournaments/up_matches.html.erb @@ -5,7 +5,23 @@ // } );