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

Description

Orchestrates the aggregation and calculation of activity statistics for a single peer mentor. Applies period filters, computes derived metrics such as hours contributed and activity type distribution, and exposes results to the UI layer. Acts as the business logic boundary between raw repository data and presentation-ready statistics.

Feature: Personal Activity Statistics

statistics-service

Sources & reasoning

Line 321 explicitly places per-peer-mentor statistics in Fase 1 (MVP). The workshop narrative (lines 16-18) confirms that making contribution visible is universally valued. The blueprint tags this feature [MVP]. Fase 1 maps to target_release "MVP" by ordinal position.

  • Enkel statistikkvisning per likeperson og per koordinator
  • Alle fire organisasjoner peker på dette som den aller viktigste funksjonen, og beskriver dagens situasjon som uholdbar.

Responsibilities

  • Aggregate raw activity records into summary metrics (total count, total hours, type breakdown)
  • Apply time period filters (current week, current month, all-time) to activity queries
  • Calculate trend data by comparing activity counts across consecutive periods
  • Expose a typed statistics model consumed by PersonalStatsScreen
  • Delegate all data access to StatisticsRepository

Interfaces

getStatsForPeriod(mentorId: String, period: TimePeriod): Future<ActivityStats>
getTrend(mentorId: String, period: TimePeriod): Future<TrendSummary>
getSummaryMetrics(mentorId: String): Future<SummaryMetrics>