From a9c6ecdf562306aaaa57b13f19abbbe2f58b53d4 Mon Sep 17 00:00:00 2001 From: Ash Gray Date: Sat, 15 Apr 2023 23:48:56 +0200 Subject: [PATCH] fix: progress in homepage --- src/routes/home.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/routes/home.js b/src/routes/home.js index 18905b1..11544c0 100644 --- a/src/routes/home.js +++ b/src/routes/home.js @@ -54,17 +54,17 @@ router.get('/', async (request, response) => { const sectionCompletionPercentage = ((done.length + in_progress.length * 0.5) / (done.length + in_progress.length + todo.length)) || 0; totalProgress._calc.percentageSum += sectionCompletionPercentage; - const sectionTitle = `${section.title} [${Math.round(sectionCompletionPercentage * 100)}%]`; + const sectionTitle = `${section.title} [${Math.floor(sectionCompletionPercentage * 100)}%]`; - if (done !== [] && in_progress + todo === []) { - // if all the section tasks have been done, push to done - totalProgress.cards.done.push(sectionTitle); - } else if (todo !== [] && in_progress + done === []) { - // if none the section tasks have been done or in_progress, push to todo - totalProgress.cards.todo.push(sectionTitle); - } else { - // for all other combos, push to in_progress - totalProgress.cards.in_progress.push(sectionTitle); + switch(sectionCompletionPercentage) { + case 0: + totalProgress.cards.todo.push(sectionTitle); + break; + case 1: + totalProgress.cards.done.push(sectionTitle); + break; + default: + totalProgress.cards.in_progress.push(sectionTitle); } });