From 5ebd050e9cbb1e03537bc14772c15d2dcd362f2d Mon Sep 17 00:00:00 2001 From: Miodec Date: Wed, 26 Oct 2022 19:12:41 +0200 Subject: [PATCH] fixed accouracy being rounded in some places instead of floored closes #3683 --- frontend/src/ts/elements/last-10-average.ts | 8 +++----- frontend/src/ts/pages/account.ts | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/frontend/src/ts/elements/last-10-average.ts b/frontend/src/ts/elements/last-10-average.ts index de8bdd402..484a50fd7 100644 --- a/frontend/src/ts/elements/last-10-average.ts +++ b/frontend/src/ts/elements/last-10-average.ts @@ -18,12 +18,10 @@ export async function update(): Promise { Config.difficulty, Config.lazyMode ) - ) - .map(Misc.roundTo2) - .map((num) => (Config.alwaysShowDecimalPlaces ? Math.round(num) : num)); + ).map(Misc.roundTo2); - averageWPM = wpm; - averageAcc = acc; + averageWPM = Config.alwaysShowDecimalPlaces ? wpm : Math.round(wpm); + averageAcc = Config.alwaysShowDecimalPlaces ? acc : Math.floor(acc); } export function getWPM(): number { diff --git a/frontend/src/ts/pages/account.ts b/frontend/src/ts/pages/account.ts index 514ac06e4..0531cae0a 100644 --- a/frontend/src/ts/pages/account.ts +++ b/frontend/src/ts/pages/account.ts @@ -878,7 +878,7 @@ function fillContent(): void { let averageAcc: number | string = totalAcc; if (Config.alwaysShowDecimalPlaces) { - averageAcc = Misc.roundTo2(averageAcc / testCount).toFixed(2); + averageAcc = Math.floor(averageAcc / testCount).toFixed(2); } else { averageAcc = Math.round(averageAcc / testCount); } @@ -887,7 +887,7 @@ function fillContent(): void { let averageAccLast10: number | string = totalAcc10; if (Config.alwaysShowDecimalPlaces) { - averageAccLast10 = Misc.roundTo2(averageAccLast10 / last10).toFixed(2); + averageAccLast10 = Math.floor(averageAccLast10 / last10).toFixed(2); } else { averageAccLast10 = Math.round(averageAccLast10 / last10); }