Module: Spotlight::JobTracking
- Extended by:
- ActiveSupport::Concern
- Includes:
- ActiveJob::Status
- Included in:
- AddTagsJob, AddUploadsFromCsv, ChangeVisibilityJob, ProcessBulkUpdatesCsvJob, ReindexExhibitJob, ReindexJob, RemoveTagsJob, RenameSidecarFieldJob, RenameTagsJob
- Defined in:
- app/jobs/concerns/spotlight/job_tracking.rb
Overview
Job status tracking
Instance Method Summary collapse
- #finalize_job_tracker! ⇒ Object
- #initialize_job_tracker!(**params) ⇒ Object
- #job_tracker ⇒ Object
- #mark_job_as_failed! ⇒ Object
Instance Method Details
#finalize_job_tracker! ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'app/jobs/concerns/spotlight/job_tracking.rb', line 46 def finalize_job_tracker! return unless job_tracker.status == 'in_progress' || job_tracker.status == 'enqueued' job_tracker.update( status: @failed ? 'failed' : 'completed', data: { progress: progress.progress, total: progress.total } ) end |
#initialize_job_tracker!(**params) ⇒ Object
42 43 44 |
# File 'app/jobs/concerns/spotlight/job_tracking.rb', line 42 def initialize_job_tracker!(**params) job_tracker.update(params.merge(status: 'in_progress').compact) end |
#job_tracker ⇒ Object
38 39 40 |
# File 'app/jobs/concerns/spotlight/job_tracking.rb', line 38 def job_tracker @job_tracker ||= find_or_initialize_job_tracker end |
#mark_job_as_failed! ⇒ Object
34 35 36 |
# File 'app/jobs/concerns/spotlight/job_tracking.rb', line 34 def mark_job_as_failed! @failed = true end |