Skip to content

Sohail: Fix role distribution chart to show complete roles data#2078

Open
sohailuddinsyed wants to merge 1 commit intodevelopmentfrom
Sohail-fix-role-distribution-chart
Open

Sohail: Fix role distribution chart to show complete roles data#2078
sohailuddinsyed wants to merge 1 commit intodevelopmentfrom
Sohail-fix-role-distribution-chart

Conversation

@sohailuddinsyed
Copy link
Contributor

Description

(PRIORITY HIGH) Yagna: Role Distribution Showing Incomplete Role Data

a. Owner Login → Dashboard → Role Distribution.
b. The Role Distribution chart currently displays only two roles, even though multiple roles exist in the system.
c. As per expected behavior, the chart should display all available roles along with their correct counts and percentages.
d. This leads to inaccurate or misleading reporting, as several existing roles are not included in the visualization.
e. The Role Distribution calculation should be updated to include all roles present in the system, ensuring the chart accurately reflects the organization’s role distribution.

Related PRS (if any):

No front end PR needed.

Main changes explained:

The Role Distribution chart on the Dashboard currently displays only two roles, even though multiple roles exist in the system (Volunteer, Manager, Administrator, Core Team, Owner, Mentor), leading to inaccurate and misleading reporting.

Root Cause: The getRoleDistributionStats function was filtering users by createdDate when date parameters were provided, which meant only users created within the selected date range were counted for role distribution. This caused several existing roles to be excluded from the visualization if no users with those roles were created in the selected time period.

Changes Made:

  • Updated the getRoleDistributionStats function in src/helpers/overviewReportHelper.js to remove the createdDate filter
  • Modified the buildMatch helper function to always return only { isActive: true } regardless of date parameters
  • Added detailed comments explaining that role distribution shows ALL active users to provide a complete picture of current organizational structure
  • Simplified the logic by removing unnecessary date filtering that was causing incomplete role data

Note: The function still accepts date parameters for backward compatibility, but they are no longer used for filtering. Role Distribution now represents the current snapshot of all active users' roles, not a date-filtered subset.

How to test:

  1. Check into current branch
  2. Do npm install and npm run dev to run this PR locally
  3. Clear site data/cache
  4. Log in as owner user
  5. Go to Dashboard → Role Distribution chart
  6. Verify that all roles present in the system are displayed (should show Volunteer, Manager, Administrator, Core Team, Owner, Mentor - whichever roles have active users)
  7. Verify that the counts and percentages accurately reflect the total number of active users in each role
  8. Optionally change the date filter and confirm all roles still display (date filter no longer affects role distribution)

Screenshots or videos of changes:

Before:
Screenshot 2026-02-28 230614
After:
Screenshot 2026-02-28 230806

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 1, 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.

1 participant