Repository navigation
fix(site): move formatMicroseconds to the next unit when rounding reaches it - #2799
Conversation
…ches it Pick the unit and digit count from the rounded value, so 999,999us reads 1.00s instead of 1,000.0ms and 9,996us reads 10.0ms instead of 10.00ms.
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f71cb6f1c5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // rather than 1000.0ms or 10.00ms. | ||
| const milliseconds = microseconds / 1000 | ||
| if (Number(milliseconds.toFixed(1)) < 1000) { | ||
| const digits = Number(milliseconds.toFixed(2)) >= 10 ? 1 : 2 |
There was a problem hiding this comment.
Match digit selection to the output formatter
When fixedDigits is left at its default and microseconds is 9_995, milliseconds.toFixed(2) is "9.99", so this selects two digits, but decimalString(9.995, 2) rounds to "10.00"; the result is 10.00ms instead of moving to 10.0ms. Select digits using the same rounding behavior as the formatter so threshold values do not retain an extra decimal place.
Useful? React with 👍 / 👎.
decimalString rounds through Intl.NumberFormat, which can differ from toFixed (9.995 -> "10.00" vs "9.99"), so 9_995us printed as 10.00ms. Round with the matching formatter when choosing the unit and digits.
|
Good catch — Pushed 74e88ea: the unit/digit selection now rounds with the same method as the formatter in use (an |
Avoids constructing Intl.NumberFormat on every call.
henrygd
left a comment
There was a problem hiding this comment.
Thank you! I simplified a bit before merging.
…ches it (henrygd#2799) Co-authored-by: hank <[email protected]> (cherry picked from commit aec15f8)
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [henrygd/beszel-agent](https://github.com/henrygd/beszel) | patch | `0.21.1` → `0.21.2` | --- ### Release Notes <details> <summary>henrygd/beszel (henrygd/beszel-agent)</summary> ### [`v0.21.2`](https://github.com/henrygd/beszel/releases/tag/v0.21.2) [Compare Source](henrygd/beszel@v0.21.1...v0.21.2) #### What's Changed - Add an actions menu with alert settings to the system detail page ([#​2803](henrygd/beszel#2803)) - Add `FAN_SENSORS` to include or exclude fan sensors ([#​2713](henrygd/beszel#2713)) - Add styled HTML alert emails ([#​2697](henrygd/beszel#2697)) - Add `no_self_update` build tag to disable hub and agent self-updates ([#​2724](henrygd/beszel#2724)) - Add warnings for missing automatic login users and trusted proxy configuration ([#​2824](henrygd/beszel#2824), [#​2812](henrygd/beszel#2812)) - Add video encode/decode engine usage to GPU metrics when using nvtop ([#​2749](henrygd/beszel#2749)) - Limit sign-in attempts to 10 per minute per address ([#​2642](henrygd/beszel#2642)) - Improve GPU collection retries and back off slow or repeatedly failing reads ([#​2705](henrygd/beszel#2705), [#​2687](henrygd/beszel#2687), [#​2709](henrygd/beszel#2709), [#​2656](henrygd/beszel#2656)) - Fix hub crashes caused by null entries in agent data ([#​2834](henrygd/beszel#2834)) - Fix agent health checks incorrectly reporting disconnected agents as healthy ([#​2825](henrygd/beszel#2825)) - Fix agent connections timing out while waiting for a slow hub ([#​2772](henrygd/beszel#2772)) - Fix container requests being canceled by requests for other systems ([#​2838](henrygd/beszel#2838)) - Fix agents being able to overwrite another system's container, service, S.M.A.R.T., or ZFS records ([#​2835](henrygd/beszel#2835)) - Fix non-admin users being able to change system users - Fix missing permission checks when moving network monitors between systems ([#​2714](henrygd/beszel#2714)) - Fix container refreshes overlapping the initial load on the All Containers page - Fix system users being overwritten when editing a system - Fix network monitors remaining on the old agent after moving to another system ([#​2739](henrygd/beszel#2739)) - Fix bulk monitor copy and import for URLs containing commas ([#​2716](henrygd/beszel#2716)) - Fix alerts not all being saved when enabling multiple alerts quickly ([#​2781](henrygd/beszel#2781)) - Fix automatic login briefly showing the login form and making redundant requests ([#​2810](henrygd/beszel#2810)) - Fix password validation on the initial setup form ([#​2744](henrygd/beszel#2744), [#​2745](henrygd/beszel#2745)) - Fix hub updates failing due to database access, working directory, or SELinux context issues ([#​2800](henrygd/beszel#2800), [#​2801](henrygd/beszel#2801), [#​2794](henrygd/beszel#2794)) - Fix historical averages including records from the previous interval ([#​2807](henrygd/beszel#2807)) - Fix failed systemd services being omitted when they have never been active ([#​2776](henrygd/beszel#2776), [#​2777](henrygd/beszel#2777)) - Fix NVMe S.M.A.R.T. data being lost when large counters exceed 64 bits ([#​2732](henrygd/beszel#2732)) - Fix degraded RAID1 arrays with remaining redundancy being reported as failed ([#​2760](henrygd/beszel#2760)) - Fix LXC memory usage incorrectly subtracting the host's ZFS ARC ([#​2767](henrygd/beszel#2767)) - Fix swap reporting on macOS ([#​2778](henrygd/beszel#2778)) - Fix container CPU counts to respect assigned CPU sets ([#​2728](henrygd/beszel#2728)) - Fix AMD GPU memory usage including GTT on devices without unified memory ([#​2715](henrygd/beszel#2715)) - Fix stale dnf5 metadata in package update checks ([#​2790](henrygd/beszel#2790)) - Fix battery data decoding with Go's experimental JSON implementation ([#​2746](henrygd/beszel#2746), [#​2748](henrygd/beszel#2748)) - Fix the agent's `-k` flag not accepting a key file path ([#​2764](henrygd/beszel#2764), [#​2765](henrygd/beszel#2765)) - Fix unreported S.M.A.R.T. power-on hours and cycles showing as zero ([#​2719](henrygd/beszel#2719)) - Update Go and Go dependencies #### New Contributors - [@​BiFangKNT](https://github.com/BiFangKNT) made their first contribution in [#​2685](henrygd/beszel#2685) - [@​metronom72](https://github.com/metronom72) made their first contribution in [#​2729](henrygd/beszel#2729) - [@​lightsabit](https://github.com/lightsabit) made their first contribution in [#​2656](henrygd/beszel#2656) - [@​cobalt-kite12](https://github.com/cobalt-kite12) made their first contribution in [#​2687](henrygd/beszel#2687) - [@​sghng](https://github.com/sghng) made their first contribution in [#​2758](henrygd/beszel#2758) - [@​aditya-rai-5](https://github.com/aditya-rai-5) made their first contribution in [#​2748](henrygd/beszel#2748) - [@​pcbeingused333](https://github.com/pcbeingused333) made their first contribution in [#​2715](henrygd/beszel#2715) - [@​duongynhi000005-oss](https://github.com/duongynhi000005-oss) made their first contribution in [#​2714](henrygd/beszel#2714) - [@​crispyaus](https://github.com/crispyaus) made their first contribution in [#​2790](henrygd/beszel#2790) - [@​rowschank](https://github.com/rowschank) made their first contribution in [#​2801](henrygd/beszel#2801) - [@​kevin9327](https://github.com/kevin9327) made their first contribution in [#​2799](henrygd/beszel#2799) - [@​Karanvir1729](https://github.com/Karanvir1729) made their first contribution in [#​2781](henrygd/beszel#2781) - [@​m1h4](https://github.com/m1h4) made their first contribution in [#​2810](henrygd/beszel#2810) - [@​ColumbusLabs](https://github.com/ColumbusLabs) made their first contribution in [#​2732](henrygd/beszel#2732) - [@​toothywalrus](https://github.com/toothywalrus) made their first contribution in [#​2812](henrygd/beszel#2812) - [@​HocVoNgThai](https://github.com/HocVoNgThai) made their first contribution in [#​2716](henrygd/beszel#2716) **Full Changelog**: <henrygd/beszel@v0.21.1...v0.21.2> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODEuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjE4MS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> --------- Co-authored-by: Renovate Bot <[email protected]> Reviewed-on: https://git.ivanch.me/ivanch/haven/pulls/47
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [ghcr.io/henrygd/beszel/beszel](https://github.com/henrygd/beszel) | patch | `0.21.1` → `0.21.2` | --- ### Release Notes <details> <summary>henrygd/beszel (ghcr.io/henrygd/beszel/beszel)</summary> ### [`v0.21.2`](https://github.com/henrygd/beszel/releases/tag/v0.21.2) [Compare Source](henrygd/beszel@v0.21.1...v0.21.2) #### What's Changed - Add an actions menu with alert settings to the system detail page ([#​2803](henrygd/beszel#2803)) - Add `FAN_SENSORS` to include or exclude fan sensors ([#​2713](henrygd/beszel#2713)) - Add styled HTML alert emails ([#​2697](henrygd/beszel#2697)) - Add `no_self_update` build tag to disable hub and agent self-updates ([#​2724](henrygd/beszel#2724)) - Add warnings for missing automatic login users and trusted proxy configuration ([#​2824](henrygd/beszel#2824), [#​2812](henrygd/beszel#2812)) - Add video encode/decode engine usage to GPU metrics when using nvtop ([#​2749](henrygd/beszel#2749)) - Limit sign-in attempts to 10 per minute per address ([#​2642](henrygd/beszel#2642)) - Improve GPU collection retries and back off slow or repeatedly failing reads ([#​2705](henrygd/beszel#2705), [#​2687](henrygd/beszel#2687), [#​2709](henrygd/beszel#2709), [#​2656](henrygd/beszel#2656)) - Fix hub crashes caused by null entries in agent data ([#​2834](henrygd/beszel#2834)) - Fix agent health checks incorrectly reporting disconnected agents as healthy ([#​2825](henrygd/beszel#2825)) - Fix agent connections timing out while waiting for a slow hub ([#​2772](henrygd/beszel#2772)) - Fix container requests being canceled by requests for other systems ([#​2838](henrygd/beszel#2838)) - Fix agents being able to overwrite another system's container, service, S.M.A.R.T., or ZFS records ([#​2835](henrygd/beszel#2835)) - Fix non-admin users being able to change system users - Fix missing permission checks when moving network monitors between systems ([#​2714](henrygd/beszel#2714)) - Fix container refreshes overlapping the initial load on the All Containers page - Fix system users being overwritten when editing a system - Fix network monitors remaining on the old agent after moving to another system ([#​2739](henrygd/beszel#2739)) - Fix bulk monitor copy and import for URLs containing commas ([#​2716](henrygd/beszel#2716)) - Fix alerts not all being saved when enabling multiple alerts quickly ([#​2781](henrygd/beszel#2781)) - Fix automatic login briefly showing the login form and making redundant requests ([#​2810](henrygd/beszel#2810)) - Fix password validation on the initial setup form ([#​2744](henrygd/beszel#2744), [#​2745](henrygd/beszel#2745)) - Fix hub updates failing due to database access, working directory, or SELinux context issues ([#​2800](henrygd/beszel#2800), [#​2801](henrygd/beszel#2801), [#​2794](henrygd/beszel#2794)) - Fix historical averages including records from the previous interval ([#​2807](henrygd/beszel#2807)) - Fix failed systemd services being omitted when they have never been active ([#​2776](henrygd/beszel#2776), [#​2777](henrygd/beszel#2777)) - Fix NVMe S.M.A.R.T. data being lost when large counters exceed 64 bits ([#​2732](henrygd/beszel#2732)) - Fix degraded RAID1 arrays with remaining redundancy being reported as failed ([#​2760](henrygd/beszel#2760)) - Fix LXC memory usage incorrectly subtracting the host's ZFS ARC ([#​2767](henrygd/beszel#2767)) - Fix swap reporting on macOS ([#​2778](henrygd/beszel#2778)) - Fix container CPU counts to respect assigned CPU sets ([#​2728](henrygd/beszel#2728)) - Fix AMD GPU memory usage including GTT on devices without unified memory ([#​2715](henrygd/beszel#2715)) - Fix stale dnf5 metadata in package update checks ([#​2790](henrygd/beszel#2790)) - Fix battery data decoding with Go's experimental JSON implementation ([#​2746](henrygd/beszel#2746), [#​2748](henrygd/beszel#2748)) - Fix the agent's `-k` flag not accepting a key file path ([#​2764](henrygd/beszel#2764), [#​2765](henrygd/beszel#2765)) - Fix unreported S.M.A.R.T. power-on hours and cycles showing as zero ([#​2719](henrygd/beszel#2719)) - Update Go and Go dependencies #### New Contributors - [@​BiFangKNT](https://github.com/BiFangKNT) made their first contribution in [#​2685](henrygd/beszel#2685) - [@​metronom72](https://github.com/metronom72) made their first contribution in [#​2729](henrygd/beszel#2729) - [@​lightsabit](https://github.com/lightsabit) made their first contribution in [#​2656](henrygd/beszel#2656) - [@​cobalt-kite12](https://github.com/cobalt-kite12) made their first contribution in [#​2687](henrygd/beszel#2687) - [@​sghng](https://github.com/sghng) made their first contribution in [#​2758](henrygd/beszel#2758) - [@​aditya-rai-5](https://github.com/aditya-rai-5) made their first contribution in [#​2748](henrygd/beszel#2748) - [@​pcbeingused333](https://github.com/pcbeingused333) made their first contribution in [#​2715](henrygd/beszel#2715) - [@​duongynhi000005-oss](https://github.com/duongynhi000005-oss) made their first contribution in [#​2714](henrygd/beszel#2714) - [@​crispyaus](https://github.com/crispyaus) made their first contribution in [#​2790](henrygd/beszel#2790) - [@​rowschank](https://github.com/rowschank) made their first contribution in [#​2801](henrygd/beszel#2801) - [@​kevin9327](https://github.com/kevin9327) made their first contribution in [#​2799](henrygd/beszel#2799) - [@​Karanvir1729](https://github.com/Karanvir1729) made their first contribution in [#​2781](henrygd/beszel#2781) - [@​m1h4](https://github.com/m1h4) made their first contribution in [#​2810](henrygd/beszel#2810) - [@​ColumbusLabs](https://github.com/ColumbusLabs) made their first contribution in [#​2732](henrygd/beszel#2732) - [@​toothywalrus](https://github.com/toothywalrus) made their first contribution in [#​2812](henrygd/beszel#2812) - [@​HocVoNgThai](https://github.com/HocVoNgThai) made their first contribution in [#​2716](henrygd/beszel#2716) **Full Changelog**: <henrygd/beszel@v0.21.1...v0.21.2> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate CLI](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0NC4xODEuNSIsInVwZGF0ZWRJblZlciI6IjQ0LjE4MS41IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> --------- Co-authored-by: Renovate Bot <[email protected]> Reviewed-on: https://git.ivanch.me/ivanch/haven/pulls/46
Problem
formatMicrosecondspicks its unit and digit count from the raw value, then rounds. A value just below a threshold rounds up past it and is printed in the smaller unit:With the default
fixedDigits,decimalStringalso adds a grouping separator, so the network monitor response time can read1,000.0msnext to1.00svalues.Fix
Choose the unit and digit count from the value as it will be printed: stay in ms only while the 1-decimal value is below 1000, and use 1 decimal once the 2-decimal value reaches 10. Nothing else changes; values away from the thresholds format exactly as before.
Test
Added a
moves to the next unit when rounding reaches itcase tointernal/site/tests/utils.test.ts(bothfixedDigitsmodes, plus values just under the thresholds that must stay put). It fails onmain(Received: "1,000.0ms") and passes with the fix:This change was prepared with AI assistance; I reviewed it and ran the test above locally.