From 9e945d444c5fecd51956a6fe6e4e917b2c2e5769 Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sun, 31 Oct 2021 08:37:58 +0000 Subject: [PATCH] [FIX] ensure correct mistake count is shown --- src/GroupStats.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/GroupStats.js b/src/GroupStats.js index 42ad004..a22c588 100644 --- a/src/GroupStats.js +++ b/src/GroupStats.js @@ -108,8 +108,9 @@ export default withRouter(class GroupStats extends Component { .get() .then((querySnapshot) => { let incorrectAnswers = []; - querySnapshot.docs - .filter((doc) => doc.data().setIds.some(item => groupSetIds.includes(item))) + const docs = querySnapshot.docs + .filter((doc) => doc.data().setIds.some(item => groupSetIds.includes(item))); + docs .map((doc, index, array) => { if (index === 0 || doc.data().term !== array[index - 1].data().term || doc.data().definition !== array[index - 1].data().definition) { incorrectAnswers.push({ @@ -148,7 +149,7 @@ export default withRouter(class GroupStats extends Component { }); newState.incorrectAnswers = incorrectAnswers.sort((a, b) => b.count + b.switchedCount - a.count - a.switchedCount); newState.filteredIncorrectAnswers = newState.incorrectAnswers; - newState.totalIncorrect = querySnapshot.docs.length; + newState.totalIncorrect = docs.length; }) .catch((error) => { newState.incorrectAnswers = [];