mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-03-09 21:26:49 +08:00
further stripping results of empty / zero values and then resetting them back to default when downloading results
This commit is contained in:
parent
7446649780
commit
a41bcad72d
2 changed files with 10 additions and 1 deletions
|
@ -298,8 +298,11 @@ export async function addResult(
|
|||
if (result.language === "english") delete result.language;
|
||||
if (result.numbers === false) delete result.numbers;
|
||||
if (result.punctuation === false) delete result.punctuation;
|
||||
|
||||
if (result.mode !== "custom") delete result.customText;
|
||||
if (result.restartCount === 0) delete result.restartCount;
|
||||
if (result.incompleteTestSeconds === 0) delete result.incompleteTestSeconds;
|
||||
if (result.afkDuration === 0) delete result.afkDuration;
|
||||
if (result.tags.length === 0) delete result.tags;
|
||||
|
||||
const addedResult = await ResultDAL.addResult(uid, result);
|
||||
|
||||
|
|
|
@ -189,6 +189,12 @@ export async function getUserResults(): Promise<boolean> {
|
|||
if (result.numbers === undefined) result.numbers = false;
|
||||
if (result.punctuation === undefined) result.punctuation = false;
|
||||
if (result.quoteLength === undefined) result.quoteLength = -1;
|
||||
if (result.restartCount === undefined) result.restartCount = 0;
|
||||
if (result.incompleteTestSeconds === undefined) {
|
||||
result.incompleteTestSeconds = 0;
|
||||
}
|
||||
if (result.afkDuration === undefined) result.afkDuration = 0;
|
||||
if (result.tags === undefined) result.tags = [];
|
||||
});
|
||||
dbSnapshot.results = results?.sort((a, b) => b.timestamp - a.timestamp);
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue