From 667f1e6a215eb0bf17bf5223fbbc91ab13c01999 Mon Sep 17 00:00:00 2001 From: ash Date: Fri, 17 Jun 2022 22:39:48 +0200 Subject: [PATCH] =?UTF-8?q?feat(progress):=20calc=20started=20features=20a?= =?UTF-8?q?s=20=C2=BD=20complete?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/js/progress-charts.js | 3 ++- src/routers/home.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/public/assets/js/progress-charts.js b/public/assets/js/progress-charts.js index cca71f3..875507e 100644 --- a/public/assets/js/progress-charts.js +++ b/public/assets/js/progress-charts.js @@ -5,9 +5,10 @@ document.querySelectorAll('.feature-list-wrapper').forEach(progressListElement = const percentageOverride = progressListElement.querySelector('canvas.percentage-chart').dataset.percentageoverride; const allFeatureNodes = progressListElement.querySelectorAll('.feature'); const allDoneFeatureNodes = progressListElement.querySelectorAll('.feature .done'); + const allStartedFeatureNodes = progressListElement.querySelectorAll('.feature .ongoing'); // Use percentage override data attribute if present, else calculate - const progressPercentage = Math.round(percentageOverride) || Math.round(Math.min((allDoneFeatureNodes.length / allFeatureNodes.length) * 100, 100)); + const progressPercentage = Math.round(percentageOverride) || Math.round(Math.min((allDoneFeatureNodes.length + allStartedFeatureNodes.length * 0.5) / allFeatureNodes.length * 100, 100)); const remainingPercentage = 100 - progressPercentage; // Set inner paragraph diff --git a/src/routers/home.js b/src/routers/home.js index 121d58a..f670c00 100644 --- a/src/routers/home.js +++ b/src/routers/home.js @@ -54,7 +54,8 @@ router.get('/', async (request, response) => { cache.sections.forEach(section => { const { not_started, started, completed } = section.progress; - const sectionCompletionPercentage = completed.length / (completed.length + started.length + not_started.length); + // Calculates the completion percentage of the project, and sums it to the total + const sectionCompletionPercentage = (completed.length + started.length * 0.5) / (completed.length + started.length + not_started.length); totalProgress._calc.percentageSum += sectionCompletionPercentage; const sectionTitle = `${section.title} [${Math.round(sectionCompletionPercentage * 100)}%]`;