Class: GoodJob::DiscreteExecution

Inherits:
BaseRecord
  • Object
show all
Includes:
ErrorEvents
Defined in:
app/models/good_job/discrete_execution.rb

Direct Known Subclasses

Execution

Constant Summary

Constants included from ErrorEvents

ErrorEvents::ERROR_EVENTS, ErrorEvents::ERROR_EVENT_ENUMS

Instance Method Summary collapse

Methods included from ErrorEvents

#error_event, #error_event=

Methods inherited from BaseRecord

bind_value, migrated?, migration_pending_warning!, with_logger_silenced

Instance Method Details

#display_serialized_paramsObject



52
53
54
55
56
# File 'app/models/good_job/discrete_execution.rb', line 52

def display_serialized_params
  serialized_params.merge({
                            _good_job_execution: attributes.except('serialized_params'),
                          })
end

#filtered_error_backtraceObject



58
59
60
# File 'app/models/good_job/discrete_execution.rb', line 58

def filtered_error_backtrace
  Rails.backtrace_cleaner.clean(error_backtrace || [])
end

#last_status_atObject



34
35
36
# File 'app/models/good_job/discrete_execution.rb', line 34

def last_status_at
  finished_at || created_at
end

#numberObject



20
21
22
# File 'app/models/good_job/discrete_execution.rb', line 20

def number
  serialized_params.fetch('executions', 0) + 1
end

#queue_latencyObject

Time between when this job was expected to run and when it started running



25
26
27
# File 'app/models/good_job/discrete_execution.rb', line 25

def queue_latency
  created_at - scheduled_at
end

#runtime_latencyObject

Monotonic time between when this job started and finished



30
31
32
# File 'app/models/good_job/discrete_execution.rb', line 30

def runtime_latency
  duration
end

#statusObject



38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/models/good_job/discrete_execution.rb', line 38

def status
  if finished_at.present?
    if error.present? && job.finished_at.present?
      :discarded
    elsif error.present?
      :retried
    else
      :succeeded
    end
  else
    :running
  end
end