Service Layer medium complexity backend
0
Dependencies
0
Dependents
4
Entities
0
Integrations

Description

A backend service that computes and aggregates personal activity statistics for a given peer mentor. It applies time-range filtering, calculates totals and trends, and formats the result for dashboard consumption. The service enforces that mentors can only access their own statistics, never those of others.

Feature: Personal Activity Statistics

statistics-service

Sources & reasoning

Line 322 explicitly lists personal and coordinator statistics as a Phase 1 MVP deliverable within the Fase 1 section heading at line 314. This maps to target_release MVP by ordinal position (first/launch phase). The feature addresses the cross-organization motivation problem and provides the data foundation for Phase 3 gamification.

  • docs/source/likeperson.md · line 322
    Enkel statistikkvisning per likeperson og per koordinator
  • docs/source/likeperson.md · line 314
    ### Fase 1 - MVP (alle organisasjoner, vår)

Responsibilities

  • Aggregate activity records by mentor ID and time range to produce totals and trends
  • Enforce access control so mentors retrieve only their own statistics
  • Compute derived metrics such as average weekly hours and streak lengths
  • Cache recent stat results to reduce database load on repeated dashboard loads
  • Expose a clean interface consumed by the PersonalStatsScreen via API

Interfaces

getPersonalStats(mentorId: string, range: TimeRange): PersonalStatsResult
getTrendData(mentorId: string, range: TimeRange): TrendPoint[]
getSummaryMetrics(mentorId: string): SummaryMetrics