Skip to content

Fixed existing issue present in 'Task Completed' bar chart - #2328

Open
Adit0717 wants to merge 1 commit into
developmentfrom
Aditya_fix_bug_totalorgsummary_hours_tasks_mismatch_be
Open

Adit0717 wants to merge 1 commit into
developmentfrom
Aditya_fix_bug_totalorgsummary_hours_tasks_mismatch_be

Conversation

@Adit0717

@Adit0717 Adit0717 commented Sep 1, 2026

Copy link
Copy Markdown

Description

Screenshot 2026-09-01 at 2 20 02 PM

Related PRS (if any):

This backend PR is related to the #5489 frontend PR.
To test this backend PR you need to checkout the #XXX frontend PR.

Main changes explained:

  • Updated the getTasksStats function in overviewReportHelper.js to include a date filter on the non-comparison branch of the aggregation query. Previously, the query had no date constraint and counted
    every task ever created in the system regardless of the selected date range. The fix count to tasks modified within the selected startDate and endDate, consistent with how the Hours Completed chart already filters its data.

How to test:

  1. check out to the current branch
  2. do npm install and run this PR locally
  3. Clear site data/cache
  4. log as admin user
  5. go to Dashboard → Total Org Summary → Volunteer Workload and Task Completion Analysis → Hours Completed / Task Completed charts → Date range selected: 6/26/2026 - 8/21/2026
  6. verify the following.,
    a. With the date range 6/26/2026 – 8/21/2026, the subtitle should read something like x% of Total Logged Hours (Tasks) | y% of Total Logged Hours (Projects) - both values visible, not just Tasks.
    b. The percentage in parentheses on each bar should match the footer split. Previously bars showed (0.00%) and (1.00%) while the footer showed 31.3% and 68.7%. After the fix, the bar labels should show the correct percentages respectively not 0% or 1%.
    c. Previously showed 1275 completed tasks for the date range 6/26/2026 – 8/21/2026. After the fix, re-run with the same date range and verify the count drops significantly to a number that is realistic for that ~2 month window.
  • The tester flagged that 1275 tasks against 25.32 hours works out to ~0.02 hours per task, which is unrealistic. The fixed count should be the correct number for the selected period.

Note:

Note that the local pre-commit related-test command may still fail because the unrelated reasonSchedulingController integration tests cannot connect to the local test database; the backend build itself succeeds.

Copilot AI lite review requested due to automatic review settings September 1, 2026 21:40

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The PR description currently lists frontend changes that are not present in this diff, which can mislead reviewers/testers about scope and verification steps.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes the “Task Completed” chart’s task counts by applying the selected date range to the non-comparison getTasksStats aggregation, so results reflect tasks modified within the requested period instead of all-time totals.

Changes:

  • Add a $match stage in the non-comparison Task.aggregate() pipeline to filter by modifiedDatetime between startDate and endDate.
  • Update the inline comment describing the non-comparison branch behavior (and align it with the actual query semantics).
File summaries
File Description
src/helpers/overviewReportHelper.js Filters non-comparison task status aggregation by the requested date range to avoid all-time task counts.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/helpers/overviewReportHelper.js
Comment on lines +1144 to +1145
// non-comparison branch — filter by the same date range so the count reflects
// tasks modified (completed/activated) within the selected period, not all time.
@sonarqubecloud

sonarqubecloud Bot commented Sep 1, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants