Infrastructure medium complexity backend
0
Dependencies
0
Dependents
2
Entities
0
Integrations

Description

Next.js REST API route (/api/v1/statistics/personal) that computes aggregated activity rollups per user using PostgreSQL window functions and GROUP BY queries. Returns pre-computed totals, breakdowns, and trend series to avoid expensive client-side aggregation. Secured by JWT middleware.

Feature: Personal Activity Statistics

statistics-api-endpoint

Responsibilities

  • Authenticate and authorize the request via JWT middleware
  • Run PostgreSQL GROUP BY and window function queries against the activities table
  • Return StatsSnapshot JSON (totals, trend series, activity type breakdown)
  • Support query parameters: userId, startDate, endDate, activityTypeId, period (day/week/month/year)

Interfaces

GET /api/v1/statistics/personal?userId&startDate&endDate&period&activityTypeId
GET /api/v1/statistics/personal/breakdown?userId&startDate&endDate
GET /api/v1/statistics/personal/trend?userId&startDate&endDate&period

Related Data Entities (2)

Data entities managed by this component