From c6a615f6f47ad1e7cae17cecb57129e6e68a1be4 Mon Sep 17 00:00:00 2001 From: Jack Date: Fri, 16 Jul 2021 23:54:41 +0100 Subject: [PATCH] updated the way filtered seconds are calculated. this should fix issue #1527 --- src/js/account.js | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/js/account.js b/src/js/account.js index fed95dea0..7ed592e7e 100644 --- a/src/js/account.js +++ b/src/js/account.js @@ -527,13 +527,16 @@ export function update() { tt = (parseFloat(result.mode2) / parseFloat(result.wpm)) * 60; } } else { - tt = parseFloat(result.testDuration); - } - if (result.incompleteTestSeconds != undefined) { - tt += result.incompleteTestSeconds; - } else if (result.restartCount != undefined && result.restartCount > 0) { - tt += (tt / 4) * result.restartCount; + tt = result.testDuration; } + + tt += (result.incompleteTestSeconds ?? 0) - (result.afkDuration ?? 0); + + // if (result.incompleteTestSeconds != undefined) { + // tt += result.incompleteTestSeconds; + // } else if (result.restartCount != undefined && result.restartCount > 0) { + // tt += (tt / 4) * result.restartCount; + // } totalSecondsFiltered += tt; if (last10 < 10) { @@ -694,24 +697,9 @@ export function update() { $(".pageAccount .triplegroup.stats").removeClass("hidden"); } - let th = Math.floor(totalSeconds / 3600); - let tm = Math.floor((totalSeconds % 3600) / 60); - let ts = Math.floor((totalSeconds % 3600) % 60); - $(".pageAccount .timeTotal .val").text(` - - ${th < 10 ? "0" + th : th}:${tm < 10 ? "0" + tm : tm}:${ - ts < 10 ? "0" + ts : ts - } - `); - let tfh = Math.floor(totalSecondsFiltered / 3600); - let tfm = Math.floor((totalSecondsFiltered % 3600) / 60); - let tfs = Math.floor((totalSecondsFiltered % 3600) % 60); - $(".pageAccount .timeTotalFiltered .val").text(` - - ${tfh < 10 ? "0" + tfh : tfh}:${tfm < 10 ? "0" + tfm : tfm}:${ - tfs < 10 ? "0" + tfs : tfs - } - `); + $(".pageAccount .timeTotalFiltered .val").text( + Misc.secondsToString(Math.round(totalSecondsFiltered), true) + ); $(".pageAccount .highestWpm .val").text(topWpm); $(".pageAccount .averageWpm .val").text(Math.round(totalWpm / testCount));