diff --git a/src/helpers/overviewReportHelper.js b/src/helpers/overviewReportHelper.js index 339161f1e..5f6b2670e 100644 --- a/src/helpers/overviewReportHelper.js +++ b/src/helpers/overviewReportHelper.js @@ -1471,10 +1471,10 @@ const overviewReportHelper = function () { /** * Aggregates total hours worked in the selected date range across all active volunteers, - * matching the dashboard's getOrgData logic exactly: + * matching the leaderboard's getLeaderboard logic: * - Uses inclusive YYYY-MM-DD boundaries matching timeEntries.dateOfWork - * - Only active users with weeklycommittedHours >= 1 and role != Mentor - * - Excludes entryType of 'person', 'team', or 'project' + * - Includes all active users + * - Excludes inactive time entries */ async function getTotalHoursWorked(startDate, endDate) { const pdtstart = @@ -1485,8 +1485,6 @@ const overviewReportHelper = function () { { $match: { isActive: true, - weeklycommittedHours: { $gte: 1 }, - role: { $ne: 'Mentor' }, }, }, { @@ -1507,7 +1505,7 @@ const overviewReportHelper = function () { $and: [ { $gte: ['$$timeentry.dateOfWork', pdtstart] }, { $lte: ['$$timeentry.dateOfWork', pdtend] }, - { $not: [{ $in: ['$$timeentry.entryType', ['person', 'team', 'project']] }] }, + { $ne: ['$$timeentry.isActive', false] }, ], }, }, diff --git a/src/helpers/overviewReportHelper.spec.js b/src/helpers/overviewReportHelper.spec.js index 1e604cceb..c6dd51d0b 100644 --- a/src/helpers/overviewReportHelper.spec.js +++ b/src/helpers/overviewReportHelper.spec.js @@ -115,6 +115,23 @@ describe('overviewReportHelper tests', () => { expect(result).toEqual({ current: 11 }); }, ); + + it('uses the same user and time-entry inclusion rules as the leaderboard', async () => { + const aggregateSpy = jest + .spyOn(UserProfile, 'aggregate') + .mockResolvedValueOnce([{ totaltime_hrs: 12.5 }]); + + const result = await overviewReportHelper().getTotalHoursWorked('2026-08-30', '2026-09-05'); + const pipeline = aggregateSpy.mock.calls[0][0]; + + expect(pipeline[0]).toEqual({ $match: { isActive: true } }); + expect(pipeline[2].$project.timeEntryData.$filter.cond.$and).toEqual([ + { $gte: ['$$timeentry.dateOfWork', '2026-08-30'] }, + { $lte: ['$$timeentry.dateOfWork', '2026-09-05'] }, + { $ne: ['$$timeentry.isActive', false] }, + ]); + expect(result).toEqual({ current: 12.5 }); + }); }); });