Data Layer high complexity backend
0
Dependencies
0
Dependents
23
Entities
0
Integrations

Description

Data access layer that executes aggregation queries against the Supabase database and manages a per-scope-key result cache with invalidation on new activity records. Caching reduces repeated heavy aggregation queries for coordinators with large peer mentor pools.

Feature: Coordinator Reports & Dashboards

coordinator-stats-repository

Responsibilities

  • Execute scoped aggregation queries for activity counts, peer mentor status, and area breakdowns
  • Maintain a per-scope-key result cache with TTL and activity-record invalidation
  • Fetch peer mentor lists scoped to a coordinator's organizational assignment
  • Support paginated query results for large organizational scopes

Interfaces

getStatsForScope(scopeKey: string, filters: FilterSet): Promise<DashboardStats>
invalidateCacheForScope(scopeKey: string)
getPeerMentorsInScope(scopeKey: string): Promise<PeerMentor[]>
getActivityCountByType(scopeKey: string, filters: FilterSet): Promise<ActivityTypeCount[]>
getInactiveMentors(scopeKey: string, inactiveDays: number): Promise<PeerMentor[]>
getAreaBreakdown(scopeKey: string): Promise<AreaStat[]>
getRawExportData(scopeKey: string, filters: FilterSet): Promise<ExportRow[]>