Module: GoodJob::Reportable
- Included in:
- Job
- Defined in:
- app/models/concerns/good_job/reportable.rb
Instance Method Summary collapse
-
#last_status_at ⇒ Object
The last relevant timestamp for this job.
-
#status ⇒ Symbol
There are 3 buckets of non-overlapping statuses: 1.
Instance Method Details
#last_status_at ⇒ Object
The last relevant timestamp for this job
36 37 38 |
# File 'app/models/concerns/good_job/reportable.rb', line 36 def last_status_at finished_at || performed_at || scheduled_at || created_at end |
#status ⇒ Symbol
There are 3 buckets of non-overlapping statuses:
1. The job will be executed
- queued: The job will execute immediately when an execution thread becomes available.
- scheduled: The job is scheduled to execute in the future.
- retried: The job previously errored on execution and will be re-executed in the future.
2. The job is being executed
- running: the job is actively being executed by an execution thread
3. The job has finished
- succeeded: The job executed successfully
- discarded: The job previously errored on execution and will not be re-executed in the future.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/models/concerns/good_job/reportable.rb', line 17 def status if finished_at.present? if error.present? :discarded else :succeeded end elsif performed_at.present? :running elsif (scheduled_at || created_at) <= DateTime.current :queued elsif error.present? :retried else :scheduled end end |