1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-03 05:27:25 +00:00
Files
wrestlingdev.com/app/models/tournament_job_status.rb

21 lines
631 B
Ruby

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