Skip to content

Commit 2a4f68d

Browse files
feat(JobsCounter): Adding a counter on Jobs indexes
1 parent 58893d9 commit 2a4f68d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

app/helpers/mission_control/jobs/interface_helper.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,20 @@ def blank_status_emoji(status)
1010
end
1111
end
1212

13+
def jobs_count_for(status)
14+
count = ActiveJob.jobs.with_status(status).count
15+
16+
number_to_human(count,
17+
format: "%n%u",
18+
units: {
19+
thousand: "K",
20+
million: "M",
21+
billion: "B",
22+
trillion: "T",
23+
quadrillion: "Q"
24+
})
25+
end
26+
1327
def modifier_for_status(status)
1428
case status.to_s
1529
when "failed" then "is-danger"

app/views/mission_control/jobs/jobs/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<% if @jobs_page.empty? %>
1212
<%= blank_status_notice "No #{jobs_status.dasherize} jobs found with the given filters" %>
1313
<% else %>
14+
<%= "Total #{jobs_status.titleize} jobs: #{jobs_count_for(jobs_status)}" %>
1415
<%= render "mission_control/jobs/jobs/jobs_page", jobs_page: @jobs_page %>
1516

1617
<%= render "mission_control/jobs/shared/pagination_toolbar", page: @jobs_page, filter_param: jobs_filter_param %>
1718
<% end %>
1819
<% end %>
19-

0 commit comments

Comments
 (0)