diff --git a/src/js/test/test-logic.js b/src/js/test/test-logic.js index fc27ac6c7..0db4149cf 100644 --- a/src/js/test/test-logic.js +++ b/src/js/test/test-logic.js @@ -1036,6 +1036,19 @@ export function finish(difficultyFailed = false) { lastTestWpm = stats.wpm; let testtime = stats.time; + + if (TestStats.lastSecondNotRound) { + let wpmAndRaw = calculateWpmAndRaw(); + TestStats.pushToWpmHistory(wpmAndRaw.wpm); + TestStats.pushToRawHistory(wpmAndRaw.raw); + TestStats.pushKeypressesToHistory(); + // errorsPerSecond.push(currentError); + // currentError = { + // count: 0, + // words: [], + // }; + } + let afkseconds = TestStats.calculateAfkSeconds(testtime); let afkSecondsPercent = Misc.roundTo2((afkseconds / testtime) * 100); @@ -1168,18 +1181,6 @@ export function finish(difficultyFailed = false) { mode2 = "zen"; } - if (TestStats.lastSecondNotRound) { - let wpmAndRaw = calculateWpmAndRaw(); - TestStats.pushToWpmHistory(wpmAndRaw.wpm); - TestStats.pushToRawHistory(wpmAndRaw.raw); - TestStats.pushKeypressesToHistory(); - // errorsPerSecond.push(currentError); - // currentError = { - // count: 0, - // words: [], - // }; - } - let labels = []; for (let i = 1; i <= TestStats.wpmHistory.length; i++) { if (TestStats.lastSecondNotRound && i === TestStats.wpmHistory.length) { @@ -1857,7 +1858,7 @@ export function finish(difficultyFailed = false) { export function fail() { input.pushHistory(); corrected.pushHistory(); - TestStats.pushKeypressesToHistory(); + // TestStats.pushKeypressesToHistory(); finish(true); let testSeconds = TestStats.calculateTestSeconds(performance.now()); let afkseconds = TestStats.calculateAfkSeconds(testSeconds); diff --git a/src/js/test/test-stats.js b/src/js/test/test-stats.js index 873a490c4..c5d99fa80 100644 --- a/src/js/test/test-stats.js +++ b/src/js/test/test-stats.js @@ -160,6 +160,7 @@ export function calculateAfkSeconds(testSeconds) { let extraAfk = 0; if (testSeconds !== undefined) { extraAfk = Math.ceil(testSeconds) - keypressPerSecond.length; + if (extraAfk < 0) extraAfk = 0; console.log("-- extra afk debug"); console.log("should be " + Math.ceil(testSeconds)); console.log(keypressPerSecond.length);