Skip to content

feat(JobsCounter): Adding a counter on Jobs indexes #253

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions app/helpers/mission_control/jobs/interface_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ def blank_status_emoji(status)
end
end

def jobs_count_for(status)
count = ActiveJob.jobs.with_status(status).count

number_to_human(count,
format: "%n%u",
units: {
thousand: "K",
million: "M",
billion: "B",
trillion: "T",
quadrillion: "Q"
})
end

def modifier_for_status(status)
case status.to_s
when "failed" then "is-danger"
Expand Down
2 changes: 1 addition & 1 deletion app/views/mission_control/jobs/jobs/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
<% if @jobs_page.empty? %>
<%= blank_status_notice "No #{jobs_status.dasherize} jobs found with the given filters" %>
<% else %>
<%= "Total #{jobs_status.titleize} jobs: #{jobs_count_for(jobs_status)}" %>
<%= render "mission_control/jobs/jobs/jobs_page", jobs_page: @jobs_page %>

<%= render "mission_control/jobs/shared/pagination_toolbar", page: @jobs_page, filter_param: jobs_filter_param %>
<% end %>
<% end %>