From 80545cce3147fbe7753e26c5689c7503a36556d2 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 12 Aug 2026 15:45:54 +0200 Subject: [PATCH] fix: fixed percentage calculation for progress items --- server/api/progress.get.ts | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/server/api/progress.get.ts b/server/api/progress.get.ts index 1e0b48c..8e7a69e 100644 --- a/server/api/progress.get.ts +++ b/server/api/progress.get.ts @@ -13,7 +13,8 @@ export default defineEventHandler(async (event): Promise => { const items: ProgressItem[] = projects.map((v) => { const totalTasks = v.tasks.length; const completedTasks = v.tasks.filter(v => v.status === 'completed').length; - const percentage = Math.floor(completedTasks / totalTasks * 100); + const halfCompletedTasks = v.tasks.filter(v => v.status === 'inprogress').length; + const percentage = Math.floor((completedTasks + (halfCompletedTasks * 0.5)) / totalTasks * 100); return { title: v.title, @@ -26,7 +27,7 @@ export default defineEventHandler(async (event): Promise => { }; }); const summedCompletion = items.reduce((a, v) => a + v.completion, 0); - const completionPercentage = Math.floor(summedCompletion / items.length * 100); + const completionPercentage = Math.floor(summedCompletion / items.length); return { completion: completionPercentage, @@ -34,20 +35,6 @@ export default defineEventHandler(async (event): Promise => { currentCents: donationData.totalDonationsCents, goalCents: donationGoalCents }, - items: projects.map((v) => { - const totalTasks = v.tasks.length; - const completedTasks = v.tasks.filter(v => v.status === 'completed').length; - const percentage = Math.floor(completedTasks / totalTasks * 100); - - return { - title: v.title, - githubUrl: v.url, - completion: percentage, - tasks: v.tasks.map(task => ({ - status: task.status, - title: task.title - })) - }; - }) + items }; });