mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-10-11 08:05:56 +08:00
fixed test getting extra afk time when they shouldnt have. fixed failed tests getting negative extra afk
This commit is contained in:
parent
4bd88690a9
commit
467e24f38b
2 changed files with 15 additions and 13 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue