Service Layer low complexity Shared Component frontendmobile
0
Dependencies
0
Dependents
1
Entities
0
Integrations

Description

Reads the volunteer's registered activity data and aggregates session count and total duration to pre-populate the calculator inputs. Depends on the activity registration data already persisted locally or fetched from Supabase.

Feature: Volunteer Benefit Calculator

activity-summary-aggregator

Summaries

The Activity Summary Aggregator eliminates manual data entry friction by automatically pre-filling the benefit calculator with a volunteer's verified session history. This automation increases the accuracy of reported impact figures because calculations are grounded in real recorded activity rather than self-reported estimates, strengthening the credibility of benefit metrics shared with funders and stakeholders. As a shared component reused across multiple product features, it provides consistent activity aggregation logic organisation-wide, reducing the risk of conflicting figures appearing in different parts of the application and reinforcing trust in the platform's reporting integrity. Accurate automated data directly supports grant reporting and outcome measurement obligations.

As a shared component, the Activity Summary Aggregator affects the delivery schedule of every feature that surfaces activity-based pre-fills, making it a high-priority dependency to stabilise early. It depends on activity registration data being available either from local persistence or Supabase, so integration testing must verify both the offline-cached and network-fetched code paths. Complexity is rated low, but shared ownership across features means any interface change carries a broad regression surface — interface contracts should be locked before dependent features enter implementation. Plan for a dedicated integration test suite covering edge cases such as mentors with zero sessions, very large session counts, and partial sync states.

Activity Summary Aggregator queries the local activity data store (or falls back to Supabase via the established data layer) filtered by mentorId, then performs in-memory aggregation to derive total session count and average session duration in minutes. The returned ActivityAggregate value object is consumed by the calculator input panel to pre-populate fields without requiring user input. Because this component is marked shared and used across multiple features, its public interface must remain stable; prefer adding overloaded or optional parameters over breaking changes. Unit tests should cover empty result sets, single-session edge cases, and duration rounding behaviour.

Ensure aggregation logic runs off the main isolate if activity record counts grow large enough to cause jank.

Responsibilities

  • Query completed activity records for the current peer mentor
  • Aggregate total session count and compute average session duration
  • Return a pre-fill value object for the calculator input panel

Interfaces

getAggregatedActivitySummary(String mentorId) → Future<ActivityAggregate>
getTotalSessions(String mentorId) → Future<int>
getAverageSessionDurationMinutes(String mentorId) → Future<int>

Related Data Entities (1)

Data entities managed by this component

API Contract

View full contract →
REST /api/v1/activity-summaries 7 endpoints
GET /api/v1/activity-summaries
GET /api/v1/activity-summaries/:mentor_id
POST /api/v1/activity-summaries
PUT /api/v1/activity-summaries/:mentor_id
DELETE /api/v1/activity-summaries/:mentor_id
GET /api/v1/activity-summaries/:mentor_id/total-sessions
+1 more