jobs: include job duration and queue delay on /jobs page.
This commit is contained in:
@@ -133,6 +133,19 @@ module ApplicationHelper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def duration_to_hhmmssms(seconds)
|
||||||
|
hh = seconds.div(1.hour).to_s
|
||||||
|
mm = seconds.div(1.minute).to_s
|
||||||
|
ss = "%.2d" % (seconds % 1.minute)
|
||||||
|
ms = ("%.3f" % (seconds % 1.second)).delete_prefix("0.")
|
||||||
|
|
||||||
|
if seconds >= 1.hour
|
||||||
|
"#{hh}:#{mm}:#{ss}.#{ms}"
|
||||||
|
else
|
||||||
|
"#{mm}:#{ss}.#{ms}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def humanized_number(number, million: "M", thousand: "k")
|
def humanized_number(number, million: "M", thousand: "k")
|
||||||
if number >= 1_000_000
|
if number >= 1_000_000
|
||||||
format("%.1f#{million}", number / 1_000_000.0)
|
format("%.1f#{million}", number / 1_000_000.0)
|
||||||
|
|||||||
@@ -62,5 +62,13 @@ class BackgroundJob < GoodJob::Job
|
|||||||
def pretty_name
|
def pretty_name
|
||||||
job_class.titleize.delete_suffix(" Job")
|
job_class.titleize.delete_suffix(" Job")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def job_duration
|
||||||
|
finished_at - performed_at if finished_at
|
||||||
|
end
|
||||||
|
|
||||||
|
def queue_delay
|
||||||
|
performed_at - created_at if performed_at
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -21,6 +21,6 @@ class BackgroundJobPolicy < ApplicationPolicy
|
|||||||
def api_attributes
|
def api_attributes
|
||||||
attributes = super
|
attributes = super
|
||||||
attributes -= [:serialized_params] unless can_see_params?
|
attributes -= [:serialized_params] unless can_see_params?
|
||||||
attributes
|
attributes + [:job_duration, :queue_delay]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,6 +32,14 @@
|
|||||||
|
|
||||||
<% t.column :status %>
|
<% t.column :status %>
|
||||||
|
|
||||||
|
<% t.column "Duration" do |job| %>
|
||||||
|
<%= duration_to_hhmmssms(job.job_duration) if job.job_duration %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% t.column "Queue Delay" do |job| %>
|
||||||
|
<%= duration_to_hhmmssms(job.queue_delay) if job.queue_delay %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% t.column "Created" do |job| %>
|
<% t.column "Created" do |job| %>
|
||||||
<%= time_ago_in_words_tagged(job.created_at) %>
|
<%= time_ago_in_words_tagged(job.created_at) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
Reference in New Issue
Block a user