Class: SolidQueueDashboard::Decorators::JobDecorator

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/solid_queue_dashboard/decorators/job_decorator.rb

Instance Method Summary collapse

Instance Method Details

#colorObject



4
5
6
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 4

def color
  Job.status_color(status)
end

#error_messageObject



61
62
63
64
65
66
67
# File 'lib/solid_queue_dashboard/decorators/job_decorator.rb', line 61

def error_message
  return @error_message if defined?(@error_message)

  @error_message = failed_execution ?
    "#{failed_execution.error["exception_class"]}: #{failed_execution.error["message"]}" :
    nil
end

#execution_historyObject



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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

Returns:

  • (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

#statusObject



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

Returns:

  • (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