From da7b915cca4e19f21d3e88dfe92cf510eee1365e Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Mon, 25 Feb 2019 22:20:30 -0800 Subject: [PATCH] Update percentage decimal places --- modules/client/main/App.js | 2 +- modules/client/utils/formatPercent.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/client/main/App.js b/modules/client/main/App.js index b16c729..41d06a8 100644 --- a/modules/client/main/App.js +++ b/modules/client/main/App.js @@ -83,7 +83,7 @@ function Stats({ data }) { of {formatBytes(totals.bandwidth.all)} of data to{' '} {formatNumber(totals.uniques.all)} unique visitors,{' '} - {formatPercent(totals.requests.cached / totals.requests.all, 0)}% + {formatPercent(totals.requests.cached / totals.requests.all, 2)}% {' '} of which were served from the cache.

diff --git a/modules/client/utils/formatPercent.js b/modules/client/utils/formatPercent.js index a88ecf5..e281005 100644 --- a/modules/client/utils/formatPercent.js +++ b/modules/client/utils/formatPercent.js @@ -1,3 +1,3 @@ -export default function formatPercent(n, fixed = 1) { - return String((n.toPrecision(2) * 100).toFixed(fixed)); +export default function formatPercent(n, decimals = 1) { + return (n * 100).toPrecision(decimals + 2); }