Update percentage decimal places

This commit is contained in:
Michael Jackson 2019-02-25 22:20:30 -08:00
parent 5df576c6be
commit da7b915cca
2 changed files with 3 additions and 3 deletions

View File

@ -83,7 +83,7 @@ function Stats({ data }) {
of <strong>{formatBytes(totals.bandwidth.all)}</strong> of data to{' '}
<strong>{formatNumber(totals.uniques.all)}</strong> unique visitors,{' '}
<strong>
{formatPercent(totals.requests.cached / totals.requests.all, 0)}%
{formatPercent(totals.requests.cached / totals.requests.all, 2)}%
</strong>{' '}
of which were served from the cache.
</p>

View File

@ -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);
}