mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-01 20:25:26 +00:00
Fixed reset password after the Devise migration.
This commit is contained in:
@@ -9,6 +9,7 @@ class Tournament < ApplicationRecord
|
||||
has_many :delegates, class_name: "TournamentDelegate"
|
||||
has_many :mat_assignment_rules, dependent: :destroy
|
||||
has_many :tournament_backups, dependent: :destroy
|
||||
has_many :tournament_job_statuses, dependent: :destroy
|
||||
|
||||
validates :date, :name, :tournament_type, :address, :director, :director_email , presence: true
|
||||
|
||||
@@ -263,6 +264,16 @@ class Tournament < ApplicationRecord
|
||||
return error_string.blank?
|
||||
end
|
||||
|
||||
# Check if there are any active jobs for this tournament
|
||||
def has_active_jobs?
|
||||
tournament_job_statuses.active.exists?
|
||||
end
|
||||
|
||||
# Get all active jobs for this tournament
|
||||
def active_jobs
|
||||
tournament_job_statuses.active
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def connection_adapter
|
||||
|
||||
20
app/models/tournament_job_status.rb
Normal file
20
app/models/tournament_job_status.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
class TournamentJobStatus < ApplicationRecord
|
||||
belongs_to :tournament
|
||||
|
||||
# Validations
|
||||
validates :job_name, presence: true
|
||||
validates :status, presence: true, inclusion: { in: ["Queued", "Running", "Errored"] }
|
||||
|
||||
# Scopes
|
||||
scope :active, -> { where.not(status: "Errored") }
|
||||
|
||||
# Class methods to find jobs for a tournament
|
||||
def self.for_tournament(tournament)
|
||||
where(tournament_id: tournament.id)
|
||||
end
|
||||
|
||||
# Clean up completed jobs (should be called when job finishes successfully)
|
||||
def self.complete_job(tournament_id, job_name)
|
||||
where(tournament_id: tournament_id, job_name: job_name).destroy_all
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user