Module: MissionControl::Jobs::JobsHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/mission_control/jobs/jobs_helper.rb

Instance Method Summary collapse

Instance Method Details

#attribute_names_for_job_status(status) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 26

def attribute_names_for_job_status(status)
  case status.to_s
  when "failed"      then [ "Error", "" ]
  when "blocked"     then [ "Queue", "Blocked by", "" ]
  when "finished"    then [ "Queue", "Finished" ]
  when "scheduled"   then [ "Queue", "Scheduled", "" ]
  when "in_progress" then [ "Queue", "Run by", "Running for" ]
  else               []
  end
end

#clean_backtrace?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 14

def clean_backtrace?
  params["clean_backtrace"] == "true"
end

#failed_job_backtrace(job, server) ⇒ Object



18
19
20
21
22
23
24
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 18

def failed_job_backtrace(job, server)
  if clean_backtrace? && server&.backtrace_cleaner
    server.backtrace_cleaner.clean(job.last_execution_error.backtrace).join("\n")
  else
    job.last_execution_error.backtrace.join("\n")
  end
end

#failed_job_error(job) ⇒ Object



10
11
12
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 10

def failed_job_error(job)
  "#{job.last_execution_error.error_class}: #{job.last_execution_error.message}"
end

#job_arguments(job) ⇒ Object



6
7
8
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 6

def job_arguments(job)
  renderable_job_arguments_for(job).join(", ")
end

#job_delayed?(job) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 37

def job_delayed?(job)
  job.scheduled_at.before?(MissionControl::Jobs.scheduled_job_delay_threshold.ago)
end

#job_title(job) ⇒ Object



2
3
4
# File 'app/helpers/mission_control/jobs/jobs_helper.rb', line 2

def job_title(job)
  job.job_class_name
end