Class: Spotlight::UpdateJobTrackersJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/spotlight/update_job_trackers_job.rb

Overview

Calls the #set_default_thumbnail method on the object passed in and calls save

Instance Method Summary collapse

Instance Method Details

#perform(job_tracker) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'app/jobs/spotlight/update_job_trackers_job.rb', line 9

def perform(job_tracker)
  reports_on = job_tracker.on

  return unless reports_on.is_a? Spotlight::JobTracker

  reports_on.update(status: 'completed') if reports_on.job_trackers.all?(&:completed?)
  reports_on.update(status: 'failed') if reports_on.job_trackers.any?(&:failed?)

  reports_on.update(data: { progress: reports_on.job_trackers.sum(&:progress), total: reports_on.job_trackers.sum(&:total) })
end