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

Description

Server-side service (Supabase Edge Function or materialized view) that aggregates activity data for the authenticated peer mentor. Computes totals by activity type, date range, and contact category. Scoped strictly to the authenticated user to prevent data leakage.

Feature: Personal Activity Statistics

statistics-calculation-service

Responsibilities

  • Aggregate activity totals by type and date range for a given user
  • Calculate hours contributed and unique contact categories assisted
  • Compute period-over-period comparisons (e.g., this month vs last month)
  • Enforce row-level security so only the owner's data is returned

Interfaces

getStatsSummary(userId, dateRange)
getActivityTotals(userId, dateRange)
getHoursBreakdown(userId, dateRange)
getContactCategoryBreakdown(userId, dateRange)
getPeriodComparison(userId, currentRange, previousRange)
getActivityStreak(userId)