Skip to content

Commit

Permalink
Improve Dashboard display of parameters (CronEntry kwargs; Process co…
Browse files Browse the repository at this point in the history
…nfiguration; Job and Execution database values) (#662)
  • Loading branch information
bensheldon committed Jul 11, 2022
1 parent 7a0e525 commit 9a5383a
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/views/good_job/jobs/_executions.erb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</div>
<% end %>
<div>
<%= tag.pre JSON.pretty_generate(execution.serialized_params), id: dom_id(execution, "params"), class: "collapse bg-light card card-body p-3 my-3" %>
<%= tag.pre JSON.pretty_generate(execution.display_serialized_params), id: dom_id(execution, "params"), class: "collapse bg-light card card-body p-3 my-3" %>
</div>
<% end %>
<% end %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/good_job/jobs/_table.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<th>Executions</th>
<th>Error</th>
<th>
ActiveJob Params&nbsp;
Parameters&nbsp;
<%= tag.button "Toggle", type: "button", class: "btn btn-sm btn-outline-primary", role: "button",
data: { bs_toggle: "collapse", bs_target: ".job-params" },
aria: { expanded: false, controls: jobs.map { |job| "##{dom_id(job, "params")}" }.join(" ") }
Expand Down Expand Up @@ -71,7 +71,7 @@
data: { bs_toggle: "collapse", bs_target: "##{dom_id(job, 'params')}" },
aria: { expanded: false, controls: dom_id(job, "params") }
%>
<%= tag.pre JSON.pretty_generate(job.serialized_params), id: dom_id(job, "params"), class: "collapse job-params" %>
<%= tag.pre JSON.pretty_generate(job.display_serialized_params), id: dom_id(job, "params"), class: "collapse job-params" %>
</td>
<td>
<div class="text-nowrap">
Expand Down
6 changes: 4 additions & 2 deletions lib/models/good_job/cron_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,11 @@ def display_properties
class: job_class,
cron: schedule,
set: display_property(set),
args: display_property(args),
description: display_property(description),
}
}.tap do |properties|
properties[:args] = display_property(args) if args.present?
properties[:kwargs] = display_property(kwargs) if kwargs.present?
end
end

private
Expand Down
8 changes: 8 additions & 0 deletions lib/models/good_job/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ def status
end
end

# Return formatted serialized_params for display in the dashboard
# @return [Hash]
def display_serialized_params
serialized_params.merge({
_good_job: attributes.except('serialized_params', 'locktype', 'owns_advisory_lock'),
})
end

def running?
if has_attribute?(:locktype)
self['locktype'].present?
Expand Down
8 changes: 8 additions & 0 deletions lib/models/good_job/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,14 @@ def recent_error
error || executions[-2]&.error
end

# Return formatted serialized_params for display in the dashboard
# @return [Hash]
def display_serialized_params
serialized_params.merge({
_good_job: attributes.except('serialized_params', 'locktype', 'owns_advisory_lock'),
})
end

# Tests whether the job is being executed right now.
# @return [Boolean]
def running?
Expand Down
2 changes: 2 additions & 0 deletions lib/models/good_job/process.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def self.current_state
hostname: Socket.gethostname,
pid: ::Process.pid,
proctitle: $PROGRAM_NAME,
preserve_job_records: GoodJob.preserve_job_records,
retry_on_unhandled_error: GoodJob.retry_on_unhandled_error,
schedulers: GoodJob::Scheduler.instances.map(&:name),
}
end
Expand Down

0 comments on commit 9a5383a

Please sign in to comment.