Change sidebar load formatting to be consistent. #3013
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
round() is not a good function to use for formatting, as it produces inconsistent results by truncating trailing zeroes. printf() produces consistent results with an appropriate format.
The format string used here is equivalent to library/uptime.c in procps, producing output equivalent to /usr/bin/uptime on Debian.
Thank you for your contribution to the Pi-hole Community!
Please read the comments below to help us consider your Pull Request.
We are all volunteers and completing the process outlined will help us review your commits quicker.
Please make sure you
What does this PR aim to accomplish?:
The system load shown in the web sidebar has inconsistent formatting, in that trailing zeroes are stripped. By long standing convention, Unix/Linux load average is presented as number rounded to 2 decimal places. Breaking from this convention can be viewed as visually ugly to veteran users; and potentially confusing for novices who may think something extra is being conveyed by the variation in formatting.
How does this PR accomplish the above?:
This moves the formatting being performed by round(), which is not intended to be used for visual formatting, to vprintf(). There is no need to round the numbers being passed around within the scripts, it is sufficient to use the automatic rounding provided by vprintf(). This change makes the load in the sidebar consistent with the output from /usr/bin/uptime on Debian (which is, in turn, consistent with the historical Unix uptime command).
Link documentation PRs if any are needed to support this PR:
By submitting this pull request, I confirm the following:
git rebase
)