From e610c647f31a5349fca799b67b2b90c8ff5f8ad2 Mon Sep 17 00:00:00 2001 From: Abhi-R0211 Date: Wed, 8 Jul 2026 00:20:44 -0400 Subject: [PATCH 1/2] fix: correct hours distribution bucket boundaries to include 50-59 and 50+ ranges --- src/helpers/overviewReportHelper.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/helpers/overviewReportHelper.js b/src/helpers/overviewReportHelper.js index 8b8bdb32a..3fa7b65e2 100644 --- a/src/helpers/overviewReportHelper.js +++ b/src/helpers/overviewReportHelper.js @@ -1357,7 +1357,8 @@ const overviewReportHelper = function () { if (weeklyAverage <= 20) return '20'; if (weeklyAverage <= 30) return '30'; if (weeklyAverage <= 40) return '40'; - return '40+'; + if (weeklyAverage <= 50) return '50'; + return '50+'; } /** @@ -1367,7 +1368,7 @@ const overviewReportHelper = function () { * - Week is Sunday to Saturday * - Count week only if 4+ days in range (exception: current week always counts) * - Round user's average to upper bucket limit - * - Buckets: 10, 20, 30, 40, 40+ + * - Buckets: 10, 20, 30, 40, 50, 50+ */ async function getHoursStats(startDate, endDate, comparisonStartDate, comparisonEndDate) { // Validate date parameters @@ -1473,7 +1474,8 @@ const overviewReportHelper = function () { 20: 0, 30: 0, 40: 0, - '40+': 0, + 50: 0, + '50+': 0, }; for (const bucket of userBuckets) { @@ -1486,7 +1488,8 @@ const overviewReportHelper = function () { { _id: '20', count: bucketCounts['20'] }, { _id: '30', count: bucketCounts['30'] }, { _id: '40', count: bucketCounts['40'] }, - { _id: '40+', count: bucketCounts['40+'] }, + { _id: '50', count: bucketCounts['50'] }, + { _id: '50+', count: bucketCounts['50+'] }, ]; return hoursStats; From c7b9df4f27aa5ad3ce496919b9a77dde4974e3e1 Mon Sep 17 00:00:00 2001 From: Abhi-R0211 Date: Mon, 13 Jul 2026 16:08:06 -0700 Subject: [PATCH 2/2] fix: use selected date range instead of hardcoded current week in getTotalHoursWorked --- src/controllers/reportsController.js | 2 +- src/helpers/overviewReportHelper.js | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/controllers/reportsController.js b/src/controllers/reportsController.js index ece247ef4..22b536f3a 100644 --- a/src/controllers/reportsController.js +++ b/src/controllers/reportsController.js @@ -191,7 +191,7 @@ const reportsController = function () { isoComparisonStartDate, isoComparisonEndDate, ), - overviewReportHelper.getTotalHoursWorked(), + overviewReportHelper.getTotalHoursWorked(isoStartDate, isoEndDate), overviewReportHelper.getTasksStats( isoStartDate, isoEndDate, diff --git a/src/helpers/overviewReportHelper.js b/src/helpers/overviewReportHelper.js index 3fa7b65e2..5d37805f5 100644 --- a/src/helpers/overviewReportHelper.js +++ b/src/helpers/overviewReportHelper.js @@ -1502,9 +1502,13 @@ const overviewReportHelper = function () { * - Only active users with weeklycommittedHours >= 1 and role != Mentor * - Excludes entryType of 'person', 'team', or 'project' */ - async function getTotalHoursWorked() { - const pdtstart = moment().tz('America/Los_Angeles').startOf('week').format('YYYY-MM-DD'); - const pdtend = moment().tz('America/Los_Angeles').endOf('week').format('YYYY-MM-DD'); + async function getTotalHoursWorked(startDate, endDate) { + const pdtstart = startDate + ? moment(startDate).format('YYYY-MM-DD') + : moment().tz('America/Los_Angeles').startOf('week').format('YYYY-MM-DD'); + const pdtend = endDate + ? moment(endDate).format('YYYY-MM-DD') + : moment().tz('America/Los_Angeles').endOf('week').format('YYYY-MM-DD'); const data = await UserProfile.aggregate([ {