Impact Calculation Service
Component Detail
Service Layer
high complexity
backend
0
Dependencies
0
Dependents
5
Entities
0
Integrations
Description
Backend service that aggregates raw activity logs, assignment honorarium records, and contact interaction data for a given user and reporting period into a structured impact summary payload. Runs server-side after each reporting period closes and persists results to the impact_summaries table for offline rendering.
impact-calculation-service
Responsibilities
- Aggregate activity logs by type, duration, and contact category for the reporting period
- Compute key metrics: total hours, unique contacts helped, activities completed, milestones reached
- Detect and populate milestone thresholds (e.g., first activity, 100-hour mark)
- Persist the computed summary as a structured JSON payload to impact_summaries
- Handle users with zero activity by producing a graceful empty-state payload
Interfaces
calculateImpactSummary(userId, periodType, year)
aggregateActivityMetrics(userId, startDate, endDate)
detectMilestones(userId, metrics)
persistSummary(userId, summaryPayload)
getSummaryForPeriod(userId, periodType, year)
triggerBatchCalculation(organizationId, periodType)
handleZeroActivityCase(userId)
Related Data Entities (5)
Data entities managed by this component