Skip to content

Commit

Permalink
Short navigation jobs count
Browse files Browse the repository at this point in the history
This patch defines the `number_to_human` format and units option to make the
navigation section titles more compact and readable.

As an example, instead of "Finished Jobs (4.4 Thousand)" it will now display
"Finished Jobs (4.4K)".

https://api.rubyonrails.org/classes/ActiveSupport/NumberHelper.html#method-i-number_to_human
  • Loading branch information
thibaudgg authored and rosa committed Oct 29, 2024
1 parent 39ace57 commit 4963d28
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/helpers/mission_control/jobs/navigation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@ def jobs_filter_param

def jobs_count_with_status(status)
count = ActiveJob.jobs.with_status(status).count
count.infinite? ? "..." : number_to_human(count)
if count.infinite?
"..."
else
number_to_human(count,
format: "%n%u",
units: {
thousand: "K",
million: "M",
billion: "B",
trillion: "T",
quadrillion: "Q"
})
end
end
end

0 comments on commit 4963d28

Please sign in to comment.