From 2beed5a2ecfb2e07fd993ed6381a91355add0f04 Mon Sep 17 00:00:00 2001 From: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Date: Thu, 1 May 2025 10:03:23 -0700 Subject: [PATCH] UI: Fix live policy response percentage rounding (#28719) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## For #27052 - Use `round` instead of `ceil` and `floor` Screenshot 2025-04-30 at 10 20 09 PM - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling --- changes/27052-round-live-policy-percentages | 1 + .../PolicyPage/components/PolicyResults/PolicyResults.tsx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 changes/27052-round-live-policy-percentages diff --git a/changes/27052-round-live-policy-percentages b/changes/27052-round-live-policy-percentages new file mode 100644 index 0000000000..3c3b734270 --- /dev/null +++ b/changes/27052-round-live-policy-percentages @@ -0,0 +1 @@ +- Fix a small bug with the way live policy result percentages were being rounded diff --git a/frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx b/frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx index 357ef9afd9..e1dafa95d8 100644 --- a/frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx +++ b/frontend/pages/policies/PolicyPage/components/PolicyResults/PolicyResults.tsx @@ -144,11 +144,11 @@ const PolicyResults = ({ {" "} (Yes:{" "} - {Math.ceil((yesCt / uiHostCounts.successful) * 100)}% + {Math.round((yesCt / uiHostCounts.successful) * 100)}% , No:{" "} - {Math.floor((noCt / uiHostCounts.successful) * 100)}% + {Math.round((noCt / uiHostCounts.successful) * 100)}% )