Aggregate Statistics Across the Full Organizational Hierarchy
National-level administrators need statistical summaries that aggregate across the full hierarchy — from individual peer mentors up through local chapters, regions, and national associations. The aggregation must correctly scope data using the hierarchy aggregation service, ensure data isolation between organizations using the multi-org data isolator, and present the results in a drill-down format so admins can move from national summary to region to individual chapter. Aggregation should be performant even with large datasets by leveraging the Supabase aggregation RPC.
User Story
Acceptance Criteria
- Given I am viewing the admin statistics dashboard, when I select a time period, then I see total activity counts, unique peer mentors active, and total hours logged rolled up across all chapters in my scope
- Given I see a national or regional aggregated figure, when I tap on it, then I drill down to see the breakdown by child units contributing to that total
- Given multiple organizations share the same backend, when I view aggregated statistics, then data from other organizations is never included in my organization's totals
- Given a region has no activity in the selected period, when I view the hierarchy stats, then the region still appears with zero values rather than being hidden
- Given I request aggregated statistics for the full hierarchy, when the data is loaded, then results are returned within 10 seconds for a dataset spanning up to 1,400 chapters
Business Value
National administrators cannot make informed resource allocation or policy decisions without hierarchy-wide statistics. Rolled-up aggregations are also a prerequisite for the automated Bufdir export feature, which is a must-have requirement for all three organizations. This story directly enables the one-click Bufdir reporting capability that is the top shared priority across NHF, Blindeforbundet, and HLF.
Components
- Hierarchy Aggregation Service service
- Hierarchy Admin Portal Screen ui
- Multi-Organization Data Isolator data
- Supabase Aggregation RPC Functions infrastructure
- Organization Unit Repository data
- Hierarchy Cache data
- Aggregation Query Builder data