Class: SolidQueueDashboard::Decorators::JobDecorator
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- SolidQueueDashboard::Decorators::JobDecorator
- Defined in:
- lib/solid_queue_dashboard/decorators/job_decorator.rb
Instance Method Summary collapse
- #color ⇒ Object
- #error_message ⇒ Object
- #execution_history ⇒ Object
- #failed? ⇒ Boolean
- #pending? ⇒ Boolean
- #retried? ⇒ Boolean
- #running? ⇒ Boolean
- #scheduled? ⇒ Boolean
- #status ⇒ Object
- #success? ⇒ Boolean
Instance Method Details
#color ⇒ Object
4 5 6 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 4 def color Job.status_color(status) end |
#error_message ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 61 def return @error_message if defined?(@error_message) @error_message = failed_execution ? "#{failed_execution.error["exception_class"]}: #{failed_execution.error["message"]}" : nil end |
#execution_history ⇒ Object
57 58 59 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 57 def execution_history SolidQueue::Job.where(active_job_id: active_job_id) end |
#failed? ⇒ Boolean
42 43 44 45 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 42 def failed? return @failed if defined?(@failed) @failed = failed_execution.present? end |
#pending? ⇒ Boolean
52 53 54 55 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 52 def pending? return @pending if defined?(@pending) @pending = !finished_at.present? && !running? end |
#retried? ⇒ Boolean
36 37 38 39 40 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 36 def retried? return @retried if defined?(@retried) @retried = finished_at.present? && !failed_execution.present? && (arguments["executions"].to_i > 0 || execution_history.where(scheduled_at: finished_at..).any?) end |
#running? ⇒ Boolean
26 27 28 29 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 26 def running? return @running if defined?(@running) @running = claimed_execution.present? end |
#scheduled? ⇒ Boolean
47 48 49 50 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 47 def scheduled? return @scheduled if defined?(@scheduled) @scheduled = scheduled_at.present? && scheduled_at > Time.current end |
#status ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 8 def status return @status if defined?(@status) @status = if running? Job::RUNNING elsif retried? Job::RETRIED elsif failed? Job::FAILED elsif success? Job::SUCCESS elsif scheduled? Job::SCHEDULED else Job::PENDING end end |
#success? ⇒ Boolean
31 32 33 34 |
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 31 def success? return @success if defined?(@success) @success = finished_at.present? && !failed? && !retried? end |