ARCHIVED: This plan was not delivered. Preserved for context.
Implementation Plan: Reporting Aggregated Charts (#460)¶
Objective¶
Implement two charts in the reporting page using already aggregated unit data:
- Unit Carbon Footprint (
tCO2-eq) - Carbon Footprint per FTE (
tCO2-eq/FTE)
Both charts must react to the same filter state as the units table.
Final Architecture¶
- Data source: existing
GET /backoffice/unitsendpoint - Backend extension: expose
emission_breakdownaggregated from modulestats.by_emission_type - Frontend integration: reuse existing result-page chart components
(
ModuleCarbonFootprintChartandCarbonFootPrintPerPersonChart) usingemission_breakdown - No new endpoint introduced
API Contract¶
- Endpoint:
GET /backoffice/units - Request filters (unchanged):
yearspath_lvl2path_lvl3path_lvl4completion_statussearch,modules,page,page_size- Response fields used by charts:
emission_breakdown.module_breakdownemission_breakdown.additional_breakdownemission_breakdown.per_person_breakdownemission_breakdown.validated_categoriesemission_breakdown.total_tonnes_co2eqemission_breakdown.total_fte
Implementation Status¶
Backend¶
- Build aggregated chart rows from
CarbonReportModule.stats.by_emission_typefor current reporting result set - Derive chart payload with backend helper
build_chart_breakdown - Expose
emission_breakdownin/backoffice/unitsresponse schema
Frontend¶
- Extend backoffice units response typing with
emission_breakdown - Reuse result-page components in reporting page:
ModuleCarbonFootprintChartCarbonFootPrintPerPersonChart- Bind reused charts to
units.emission_breakdown
Validation Checklist¶
- Compare chart values against aggregated emission type totals from module stats
- Verify per-person chart behavior for headcount validated/non-validated cases
- Verify year and hierarchy filters update table + charts together
- Verify completion filter updates table + charts together
- Verify chart rendering when filtered result set is empty
Non-Goals¶
- No dedicated charts endpoint
- No additional pagination strategy for charts in this iteration
Risks / Follow-ups¶
- Aggregation currently uses current page report IDs (page-scoped charts); if full filtered aggregation is required across all pages, add a dedicated aggregate query in follow-up
- Missing or stale module stats would directly impact chart accuracy