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

Description

Data access layer for querying activity statistics, snapshot data, and aggregated metrics from PostgreSQL. Provides optimized aggregate queries with organization_id, created_at, and status indexes for dashboard performance.

Feature: Dashboard KPIs

statistics-repository

Responsibilities

  • Execute aggregate SQL queries for activity counts and peer mentor metrics
  • Read and write statistics_snapshots for caching aggregated results
  • Query reporting_periods for current period boundaries
  • Enforce organization_id scoping on all queries to prevent cross-tenant data leakage

Interfaces

getActivityStats(organizationId: string, from: Date, to: Date): Promise<ActivityStats>
getPeerMentorStats(organizationId: string): Promise<PeerMentorStats>
getApprovalStats(organizationId: string): Promise<ApprovalStats>
saveSnapshot(snapshot: StatisticsSnapshot): Promise<void>
getLatestSnapshot(organizationId: string): Promise<StatisticsSnapshot | null>

Relationships

Dependents (1)

Components that depend on this component