Gayatri -Fix taskHours always returning 0 in getTaskAndProjectStats - #2322
Conversation
|
devangsaraogi
left a comment
There was a problem hiding this comment.
Hi @sawantgayatri19,
I reviewed and tested PR #2322 locally. I verified the taskandprojectstats endpoint across multiple date ranges and confirmed it returns consistent task/project hour totals and percentage calculations without errors.
I also reviewed the aggregation change and confirmed that including default, person and null matches the task-level time-entry categorization already used elsewhere in the application.
I investigated the previously reported /totalorgsummary “Something went wrong” issue as well. I reproduced the same page failure on the PR’s exact base commit, so it appears to be pre-existing rather than introduced by this change.
I wasn’t able to produce a local person entry in the available test data for a direct before/after comparison but I found no PR-specific regression or blocking issue and CI is passing.
Approved.
|
Thank you all, merging! |




Description
Fixed a bug on the Total Org Summary dashboard where the "Hours Completed" chart's Tasks bar always showed 0 hours, regardless of the selected date range, while Project hours displayed correctly. The related "Task Completed" widget (Assigned/Completed counts) on the same page was affected by the same underlying issue.
The root cause was in
getTaskHoursinsideoverviewReportHelper.js. The MongoDB aggregation filtered time entries using:This incorrectly excluded entries with
entryType: 'person'. However,'person'is a legitimate entryType for individual task-level time entries in this app — confirmed by the same categorization pattern already used elsewhere in this same file (line ~1043) and in the frontend (src/actions/timeEntries.js), which both treat'default'and'person'as equivalent task-level entry types. Since most real task time entries are logged withentryType: 'person', the filter was silently excluding nearly all of them, causingtaskHours.countto always return 0.Fixes ticket #1335 (P1/Total Org Summary: "Hours Completed" chart shows 0 hours for Tasks and very low hours for Project).
Related PRs (if any):
None.
Main changes explained:
src/helpers/overviewReportHelper.js: changed thegetTaskHoursaggregation's$matchfilter fromentryType: { $nin: ['person', 'team', 'project'] }toentryType: { $in: ['default', 'person', null] }, matching the categorization pattern already used elsewhere in this file for task/individual-level time entries.How to test:
npm installandnpm run devto run the backend locallyHighestGoodNetworkApp) and log in as admin/totalorgsummary)Screenshots or videos of changes:
Note:
Full backend test suite: 146/147 suites pass. The one failing suite (
reasonSchedulingController.test.js) fails identically with and without this change — confirmed viagit stashtesting — due to a pre-existing local MongoDB connection timeout in the dev environment, unrelated to this fix.overviewReportHelper.spec.js(7/7 tests) passes.