-
-
Notifications
You must be signed in to change notification settings - Fork 40
Aditya feat: Add donutChartData with mutually exclusive volunteer categories #1794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Aditya feat: Add donutChartData with mutually exclusive volunteer categories #1794
Conversation
- Add donutChartData object with three categories: existingActive, newActive, deactivated - Include count, percentageOutOfTotal, and optional comparisonPercentage for each category - Calculate existingActive as activeVolunteers minus newVolunteers to prevent double counting - Add comparison percentage support for all donut chart categories - Fix: Add optional chaining to Blue Square stats to prevent crashes on empty data - Ensure all percentages sum to 1.00 and maintain mathematical consistency - Backward compatible: existing API fields remain unchanged
Aswin20010
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed PR #4191+1794 update that introduces support for the new donutChartData structure in the Volunteer Status chart. Verified correct extraction of nested .count properties from existingActive, newActive, and deactivated categories, along with backward compatibility for the legacy data format. Confirmed updated chart labels (“Existing Active,” “New Active,” and “Deactivated”) accurately reflect volunteer status categories and display proper color coding. Tested hybrid data access logic with optional chaining and default values to ensure no rendering or NaN% errors occur. Validated that the metric cards continue to function using the original data structure without regression. Conducted end-to-end testing under Dashboard → Reports → Total Organization Summary after clearing cache and reinstalling dependencies. Checked percentage accuracy, total count display, and dynamic updates upon changing date ranges. No UI, data, or logic issues found — approved the PR.



deep3072
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Thank you all, merging! |












Description
This PR implements a new
donutChartDataobject in the volunteer statistics API to provide three mutually exclusive volunteer categories for improved donut chart visualization and accurate reporting. Additionally, it includes critical bug fixes to prevent application crashes when no Blue Square data exists.Implements: Volunteer Status Donut Chart with Mutually Exclusive Categories

Related PRs (if any):
Main changes explained:
Added
donutChartDataObject (src/helpers/overviewReportHelper.js)donutChartDataobject in thegetVolunteerNumberStatsfunction responseexistingActive: Active volunteers who are not new (calculated asactiveVolunteers - newVolunteers)newActive: New volunteers created within the date rangedeactivated: All inactive volunteerscount: The number of volunteers in that categorypercentageOutOfTotal: Rounded percentage (2 decimal places) calculated against total volunteerscomparisonPercentage(optional): Growth/decline percentage when comparison dates are provided.Added Comparison Data for Donut Chart (
src/helpers/overviewReportHelper.js)comparisonStartDateandcomparisonEndDateare providedcalculateGrowthPercentagehelper function for consistencyBug Fix: Added Optional Chaining for Blue Square Stats (
src/helpers/overviewReportHelper.js)?.) and default values (|| 0) to prevent crashes when no Blue Square infringement data existsThe implementation ensures:
activeVolunteers.count = donutChartData.existingActive.count + donutChartData.newActive.counttotalVolunteers.count = activeVolunteers.count + deactivatedVolunteers.countdonutChartData.existingActive.count + donutChartData.newActive.count + donutChartData.deactivated.count = totalVolunteers.countHow to test:
Prerequisites:
Aditya-fix/volunteer-status-donut-chart-percentagesrm -rf node_modules package-lock.json && npm cache clean --forcenpm installto install dependenciesnpm run devTest Cases:
API Testing Instructions:
Check
Test 1: Basic Request (No Comparison)
Request:
http://localhost:4500/api/reports/volunteerstats?startDate=2024-01-01&endDate=2024-12-31Verify:
donutChartDataobject with three categories:existingActive,newActive,deactivatedcountandpercentageOutOfTotalfieldscomparisonPercentagefields presentactiveVolunteers.countequalsexistingActive.count + newActive.countTest 2: With Comparison Dates
Request:
http://localhost:4500/api/reports/volunteerstats?startDate=2024-01-01&endDate=2024-12-31&comparisonStartDate=2023-01-01&comparisonEndDate=2023-12-31Verify:
comparisonPercentagefieldTest 3: Mathematical Consistency
Using any successful response, verify:
activeVolunteers.count === (existingActive.count + newActive.count)totalVolunteers.count === (activeVolunteers.count + deactivatedVolunteers.count)totalVolunteers.countTest 4: Missing Parameters
Request:
http://localhost:4500/api/reports/volunteerstats(no query params)Verify:
Screenshots or videos of changes:
TestingVideo.mov
Note:
donutChartDatain the JSON response object to verify the data.