Round Remaining Namespace Storage in Notification Email to Match Banner
What does this MR do and why?
When the total namespace storage crosses a warning threshold, we display a banner and we also send an email.
Sometimes there is a slight discrepancy in consumed storage percentage reported in the banner vs the email.
We calculate the percent by two different functions. One of these functions rounds, the other uses floor
to always round down. So sometimes the percentages are off by 1.
- The banner uses
number_to_percentage
in this function, which rounds:
[64] pry(main)> number_to_percentage(0.6, precision: 0)
=> "1%"
[65] pry(main)> number_to_percentage(0.4, precision: 0)
=> "0%"
[66] pry(main)>
- The email uses
floor
in this function.
This MR changes the email function to use round
as well.
Issue: https://gitlab.com/gitlab-org/gitlab/-/issues/422103
Screenshots or screen recordings
Note that in the first screenshot, the banner reports 89% storage consumed, while the email reports 88%.
In the second screenshot, both the banner and the email match and report 89% consumed.
Before | After |
---|---|
![]() |
![]() |
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.