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

Description

Riverpod AsyncNotifierProvider that queries the local Drift database to aggregate the current user's activity data into typed statistics models. Handles client-side date bucketing (week/month/year) entirely offline, computes streaks and personal bests, and invalidates automatically on sync-completion events so figures update without a manual refresh.

Feature: Personal Activity Statistics

statistics-service

Responsibilities

  • Query the Drift activities table filtered by current user ID and the selected time-range bucket
  • Aggregate total activity count, total hours, unique contacts supported, and per-bucket series data
  • Compute current streak (consecutive days/weeks with at least one activity) and personal-best record
  • Calculate month-over-month delta for the motivational comparison card
  • Listen to sync-completion events from the background sync service and invalidate provider state

Interfaces

watch(TimeBucket) → AsyncValue<PersonalStatsModel>
getStreak() → StreakModel
getPersonalBest() → PersonalBestModel
getMonthDelta() → MonthDeltaModel
invalidateOnSyncComplete() → void

Relationships

Dependencies (1)

Components this component depends on

Dependents (1)

Components that depend on this component