Data Layer medium complexity mobile
0
Dependencies
2
Dependents
3
Entities
1
Integrations

Description

Data access layer that queries Supabase pre-aggregated views for activity statistics. All queries target views pre-aggregated by org_id + coordinator_id + month, reducing real-time computation cost. RLS on the Supabase side enforces data isolation.

Feature: Coordinator Statistics Dashboard

stats-repository

Responsibilities

  • Query aggregated stats views with org_id + coordinator_id + month filters
  • Deserialize Supabase response rows into typed Dart model objects
  • Support period range filtering and activity type filtering
  • Expose both coordinator-scoped and org-wide query methods

Interfaces

fetchCoordinatorAggregates(String orgId, String coordinatorId, DateRange period) → Future<List<CoordinatorAggregateRow>>
fetchOrgAggregates(String orgId, DateRange period) → Future<List<OrgAggregateRow>>
fetchActivityTypeBreakdown(String coordinatorId, DateRange period, {String? activityTypeId}) → Future<List<ActivityTypeBreakdownRow>>
fetchPeerMentorRosterStats(String coordinatorId, DateRange period) → Future<List<PeerMentorStatRow>>
fetchPersonalStats(String mentorId, DateRange period) → Future<PersonalStatsRow>
fetchPendingReimbursementTotal(String coordinatorId) → Future<double>

Relationships

Dependents (2)

Components that depend on this component

Related Data Entities (3)

Data entities managed by this component

Used Integrations (1)

External integrations and APIs this component relies on

API Contract

View full contract →
REST /api/v1/stats 9 endpoints
GET /api/v1/stats/peer-mentor
GET /api/v1/stats/peer-mentor/:userId
POST /api/v1/stats/peer-mentor
PUT /api/v1/stats/peer-mentor/:userId
DELETE /api/v1/stats/peer-mentor/:userId
GET /api/v1/stats/coordinator
+3 more