Data Layer medium complexity backend
0
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

A data access layer responsible for querying activity records and aggregating raw statistics for a specific peer mentor. It runs time-bounded queries against the activity log tables and returns structured data to the StatisticsService. Offline-capable read paths allow cached stat snapshots to be served when connectivity is unavailable.

Feature: Personal Activity Statistics

statistics-repository

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

  • Query activity records filtered by mentor ID and date range
  • Aggregate totals (hours, activity count) using database-level grouping for efficiency
  • Return time-series data points suitable for trend chart rendering
  • Cache recent query results locally to support offline stat reads
  • Invalidate cached results when new activity records are saved

Interfaces

findActivitiesByMentor(mentorId: string, from: Date, to: Date): Activity[]
getAggregateTotals(mentorId: string, range: TimeRange): AggregateTotals
getTrendSeries(mentorId: string, range: TimeRange, granularity: Granularity): TrendPoint[]

Related Data Entities (1)

Data entities managed by this component