From 5191e7fc1e0a319a10002f389b944ef5058c06ff Mon Sep 17 00:00:00 2001 From: Miodec Date: Mon, 31 Jan 2022 23:14:36 +0100 Subject: [PATCH] checking tags when calculating average closes #2373 --- src/js/db.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/js/db.js b/src/js/db.js index 4890883ca..dfde91510 100644 --- a/src/js/db.js +++ b/src/js/db.js @@ -265,6 +265,13 @@ export async function getUserAverageWpm10( lazyMode ) { function cont() { + let activeTagIds = []; + getSnapshot()?.tags?.forEach((tag) => { + if (tag.active === true) { + activeTagIds.push(tag._id); + } + }); + let wpmSum = 0; let count = 0; let last10Wpm = 0; @@ -277,7 +284,10 @@ export async function getUserAverageWpm10( result.language == language && result.difficulty == difficulty && (result.lazyMode === lazyMode || - (result.lazyMode === undefined && lazyMode === false)) + (result.lazyMode === undefined && lazyMode === false)) && + ((activeTagIds.length === 0 && result.tags.length === 0) || + (activeTagIds.length > 0 && + result.tags.some((tag) => activeTagIds.includes(tag)))) ) { // Continue if the mode2 doesn't match unless it's a quote. if (result.mode2 != mode2 && mode != "quote") {