1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-04 22:03:49 +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

@@ -31,12 +31,18 @@ class School < ActiveRecord::Base
end
def calculate_score
newScore = total_points_scored_by_wrestlers - total_points_deducted
if Rails.env.production?
self.delay(:job_owner_id => self.tournament.id, :job_owner_type => "Calculate team score for #{self.name}").calculate_score_raw
else
calculate_score_raw
end
end
def calculate_score_raw
newScore = total_points_scored_by_wrestlers - total_points_deducted
self.score = newScore
self.save
end
if Rails.env.production?
handle_asynchronously :calculate_score
end
def total_points_scored_by_wrestlers

View File

@@ -12,6 +12,10 @@ class Tournament < ActiveRecord::Base
attr_accessor :import_text
def deferred_jobs
Delayed::Job.where(job_owner_id: self.id)
end
def self.search(search)
where("date LIKE ? or name LIKE ?", "%#{search}%", "%#{search}%")
end