Class: JobBoard::JobRow
- Inherits:
-
Object
- Object
- JobBoard::JobRow
- Defined in:
- app/models/job_board/job_row.rb
Overview
Uniform row facade so the jobs table doesn't care whether a row came from an execution record or a finished job.
Instance Attribute Summary collapse
-
#execution ⇒ Object
readonly
Returns the value of attribute execution.
-
#job ⇒ Object
readonly
Returns the value of attribute job.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #class_name ⇒ Object
- #concurrency_key ⇒ Object
- #enqueued_at ⇒ Object
- #error_class ⇒ Object
- #error_message ⇒ Object
- #finished_at ⇒ Object
- #id ⇒ Object
-
#initialize(job:, status:, execution: nil) ⇒ JobRow
constructor
A new instance of JobRow.
- #priority ⇒ Object
- #process ⇒ Object
- #queue_name ⇒ Object
- #scheduled_at ⇒ Object
Constructor Details
#initialize(job:, status:, execution: nil) ⇒ JobRow
Returns a new instance of JobRow.
15 16 17 18 19 |
# File 'app/models/job_board/job_row.rb', line 15 def initialize(job:, status:, execution: nil) @job = job @status = status.to_sym @execution = execution end |
Instance Attribute Details
#execution ⇒ Object (readonly)
Returns the value of attribute execution.
5 6 7 |
# File 'app/models/job_board/job_row.rb', line 5 def execution @execution end |
#job ⇒ Object (readonly)
Returns the value of attribute job.
5 6 7 |
# File 'app/models/job_board/job_row.rb', line 5 def job @job end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'app/models/job_board/job_row.rb', line 5 def status @status end |
Class Method Details
.from_execution(execution, status:) ⇒ Object
7 8 9 |
# File 'app/models/job_board/job_row.rb', line 7 def self.from_execution(execution, status:) new(job: execution.job, status: status, execution: execution) end |
.from_job(job, status: :finished) ⇒ Object
11 12 13 |
# File 'app/models/job_board/job_row.rb', line 11 def self.from_job(job, status: :finished) new(job: job, status: status) end |
Instance Method Details
#class_name ⇒ Object
23 |
# File 'app/models/job_board/job_row.rb', line 23 def class_name = job.class_name |
#concurrency_key ⇒ Object
36 37 38 |
# File 'app/models/job_board/job_row.rb', line 36 def concurrency_key execution.concurrency_key if status == :blocked && execution end |
#enqueued_at ⇒ Object
25 |
# File 'app/models/job_board/job_row.rb', line 25 def enqueued_at = job.created_at |
#error_class ⇒ Object
40 41 42 |
# File 'app/models/job_board/job_row.rb', line 40 def error_class execution.exception_class if status == :failed && execution end |
#error_message ⇒ Object
44 45 46 |
# File 'app/models/job_board/job_row.rb', line 44 def execution. if status == :failed && execution end |
#finished_at ⇒ Object
26 |
# File 'app/models/job_board/job_row.rb', line 26 def finished_at = job.finished_at |
#id ⇒ Object
21 |
# File 'app/models/job_board/job_row.rb', line 21 def id = job.id |
#priority ⇒ Object
24 |
# File 'app/models/job_board/job_row.rb', line 24 def priority = job.priority |
#process ⇒ Object
32 33 34 |
# File 'app/models/job_board/job_row.rb', line 32 def process execution.process if status == :claimed && execution end |
#queue_name ⇒ Object
22 |
# File 'app/models/job_board/job_row.rb', line 22 def queue_name = job.queue_name |
#scheduled_at ⇒ Object
28 29 30 |
# File 'app/models/job_board/job_row.rb', line 28 def scheduled_at status == :scheduled ? execution.scheduled_at : job.scheduled_at end |