Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Dashboard display of parameters (CronEntry kwargs; Process configuration; Job and Execution database values) #662

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -297,6 +297,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?
performed_at? && !finished_at?
end
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 @@ -117,6 +117,14 @@ def recent_error
head_execution.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