Stats Aggregation Service
Component Detail
Service Layer
medium complexity
backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations
Description
Backend service that aggregates raw activity records into personal statistics for a single mentor. Computes totals and time-bucketed trends, enforcing role-based scoping so a mentor only ever sees their own data.
stats-aggregation-service
Sources & reasoning
MVP scope in §5 explicitly lists 'Enkel statistikkvisning per likeperson' and §7 Phase 1 repeats 'enkel statistikk' - making this a Phase 1 must_have. It is the data foundation that later gamification (Phase 3 Wrapped/badges) reads from, so it ships first.
-
docs/source/likeperson.md · line 240Enkel statistikkvisning per likeperson og per koordinator
-
docs/source/likeperson.md · line 307Mobil: aktivitetsregistrering, WCAG, enkel statistikk
-
docs/source/likeperson.md · line 46-47Tre organisasjoner er inspirert av Spotify Wrapped og ønsker en funksjon som viser likepersonens bidrag over tid - «Din likepersonsårek».
Responsibilities
- Aggregate logged activities into totals for activities, hours, and contacts supported
- Compute weekly, monthly, and yearly trend series for charting
- Enforce role-based access so results are scoped to the requesting mentor
- Return shaped DTOs optimised for mobile rendering and minimal payload size
- Handle empty datasets gracefully and surface validation errors clearly
Interfaces
getPersonalTotals(mentorId): PersonalTotals
getTrendSeries(mentorId, period: 'week' | 'month' | 'year'): TrendSeries
getPersonalStatsSummary(mentorId): PersonalStatsSummary