From 0448a425d4e5138c98a6d1b3e2bae87916c10ba6 Mon Sep 17 00:00:00 2001 From: Miodec Date: Fri, 6 Aug 2021 18:42:02 +0100 Subject: [PATCH] changed the way char stats are stored and displayed --- backend/migrate.js | 10 +++++++++- src/js/account.js | 10 ++++++++-- src/js/db.js | 3 +++ src/js/test/test-logic.js | 12 +++++++++--- static/index.html | 22 ++++++---------------- 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/backend/migrate.js b/backend/migrate.js index ac6ffb493..5d07f5bc0 100644 --- a/backend/migrate.js +++ b/backend/migrate.js @@ -176,7 +176,15 @@ async function migrateUsers() { if (resultData.tags && resultData.tags.length > 0) { resultData.tags = resultData.tags.map((tag) => tagPairs[tag]); } - newStats.completedTests++; + if (!resultData.charStats) { + resultData.charStats = [ + resultData.correctChars, + resultData.incorrectChars, + ]; + } + delete resultData.correctChars; + delete resultData.incorrectChars; + resultData.charStats = newStats.completedTests++; if (resultData.restartCount) { newStats.startedTests += resultData.restartCount + 1; } else { diff --git a/src/js/account.js b/src/js/account.js index a29ef4a89..9931b1ed3 100644 --- a/src/js/account.js +++ b/src/js/account.js @@ -285,15 +285,21 @@ function loadMoreLines(lineIndex) { pb = ""; } + let charStats = "-"; + if (result.charStats) { + charStats = result.charStats.join("/"); + } else { + charStats = result.correctChars + "/" + result.incorrectChars + "/-/-"; + } + $(".pageAccount .history table tbody").append(` ${pb} ${result.wpm.toFixed(2)} ${raw} ${result.acc.toFixed(2)}% - ${result.correctChars} - ${result.incorrectChars} ${consistency} + ${charStats} ${result.mode} ${result.mode2}${withpunc} ${icons} ${tagIcons} diff --git a/src/js/db.js b/src/js/db.js index 525b3b4b8..9bdfaf6fe 100644 --- a/src/js/db.js +++ b/src/js/db.js @@ -138,6 +138,9 @@ export async function getUserResults() { if (result.numbers === undefined) result.numbers = false; if (result.punctuation === undefined) result.punctuation = false; }); + results.data = results.data.sort((a, b) => { + return a.timestamp < b.timestamp; + }); dbSnapshot.results = results.data; await TodayTracker.addAllFromToday(); return true; diff --git a/src/js/test/test-logic.js b/src/js/test/test-logic.js index 0a2546064..b0b5ff85e 100644 --- a/src/js/test/test-logic.js +++ b/src/js/test/test-logic.js @@ -1479,9 +1479,15 @@ export function finish(difficultyFailed = false) { let completedEvent = { wpm: stats.wpm, rawWpm: stats.wpmRaw, - correctChars: stats.correctChars + stats.correctSpaces, - incorrectChars: stats.incorrectChars, - allChars: stats.allChars, + // correctChars: stats.correctChars + stats.correctSpaces, + // incorrectChars: stats.incorrectChars, + // allChars: stats.allChars, + charStats: [ + stats.correctChars + stats.correctSpaces, + stats.incorrectChars, + stats.extraChars, + stats.missedChars, + ], acc: stats.acc, mode: Config.mode, mode2: mode2, diff --git a/static/index.html b/static/index.html index 38e3fb306..f608ad861 100644 --- a/static/index.html +++ b/static/index.html @@ -4394,28 +4394,18 @@ accuracy - - correct -
- chars - - - incorrect -
- chars - consistency + + chars + mode info