Skip to content

Ansh - 馃敟 Total Org Summary badge stats aggregation - #2336

Merged
one-community merged 1 commit into
developmentfrom
Ansh_fix_total_org_summary_stats
Sep 6, 2026
Merged

Ansh - 馃敟 Total Org Summary badge stats aggregation#2336
one-community merged 1 commit into
developmentfrom
Ansh_fix_total_org_summary_stats

Conversation

@AnshShah-18

Copy link
Copy Markdown
Contributor

Description

Total Org Summary was still failing after the frontend crash was fixed because the /reports/volunteerstats endpoint returned a 500 error during badge statistics aggregation.

The failure occurred when $regexMatch received a non-string badgeCollection.earnedDate value.

This hotfix safely converts earnedDate values to strings before applying regex and substring operations.

Root Cause

getTotalBadgesAwardedCount() assumed all badgeCollection.earnedDate values were strings.

At least one badge record contained an earnedDate value with a different type, causing MongoDB to throw:

$regexMatch needs 'input' to be of type string

That exception caused the volunteer stats endpoint to return 500 and prevented Total Org Summary from loading.

Main Changes

  • Convert badgeCollection.earnedDate to a string using $convert
  • Handle null/error values safely
  • Use the normalized string for regex and substring operations
  • Preserve the existing badge date parsing behavior

How to test

  1. Run HGNRest locally.
  2. Run the frontend locally.
  3. Log in as an admin.
  4. Navigate to Total Org Summary.
  5. Verify Total Org Summary loads normally.

Related Frontend PR

Frontend hotfix: OneCommunityGlobal/HighestGoodNetworkApp#5512

@sonarqubecloud

sonarqubecloud Bot commented Sep 6, 2026

Copy link
Copy Markdown

@one-community
one-community merged commit 8de2c72 into development Sep 6, 2026
4 checks passed
@one-community one-community changed the title Ansh - fix Total Org Summary badge stats aggregation Ansh - 馃敟 Total Org Summary badge stats aggregation Sep 6, 2026
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