@@ -963,33 +963,27 @@ const overviewReportHelper = function () {
963963
964964 /** aggregates role distribution statistics
965965 * counts total number of volunteers that fall within each of the different roles
966+ * NOTE: This shows ALL active users regardless of createdDate to provide
967+ * a complete picture of current role distribution in the organization
966968 */
967969 async function getRoleDistributionStats (
968970 startDate ,
969971 endDate ,
970972 comparisonStartDate ,
971973 comparisonEndDate ,
972974 ) {
973- // Helper to build match stage depending on whether start/end are provided
974- const buildMatch = ( s , e ) => {
975- const match = { isActive : true } ;
976- if ( s && e ) {
977- match . createdDate = { $gte : new Date ( s ) , $lte : new Date ( e ) } ;
978- }
979- return match ;
980- } ;
975+ // Always match only active users, ignore date filters for role distribution
976+ // This ensures all current roles are displayed, not just recently created users
977+ const buildMatch = ( ) => ( { isActive : true } ) ;
981978
982979 // If comparison dates provided, return both current and comparison facets
983980 if ( comparisonStartDate && comparisonEndDate ) {
984981 const roleStats = await UserProfile . aggregate ( [
985982 {
986983 $facet : {
987- current : [
988- { $match : buildMatch ( startDate , endDate ) } ,
989- { $group : { _id : '$role' , count : { $sum : 1 } } } ,
990- ] ,
984+ current : [ { $match : buildMatch ( ) } , { $group : { _id : '$role' , count : { $sum : 1 } } } ] ,
991985 comparison : [
992- { $match : buildMatch ( comparisonStartDate , comparisonEndDate ) } ,
986+ { $match : buildMatch ( ) } ,
993987 { $group : { _id : '$role' , count : { $sum : 1 } } } ,
994988 ] ,
995989 } ,
@@ -1003,7 +997,7 @@ const overviewReportHelper = function () {
1003997 }
1004998
1005999 // No comparison: return same shape as before (array of {_id: role, count})
1006- const matchStage = buildMatch ( startDate , endDate ) ;
1000+ const matchStage = buildMatch ( ) ;
10071001 const result = await UserProfile . aggregate ( [
10081002 { $match : matchStage } ,
10091003 { $group : { _id : '$role' , count : { $sum : 1 } } } ,
0 commit comments