Define ActivitySummary model and query interface
epic-benefit-calculator-foundation-task-004 — Create the ActivitySummary data class with fields: sessionCount (int), averageDurationMinutes (double), totalDurationMinutes (double), periodStart (DateTime), periodEnd (DateTime). Define the abstract ActivitySummaryRepository interface with a method getActivitySummaryForMentor(mentorId, dateRange). This interface decouples the aggregator service from the Supabase implementation.
Acceptance Criteria
Technical Requirements
Implementation Notes
Place ActivitySummary and DateRange in lib/features/benefit_calculator/domain/models/. Place IActivitySummaryRepository in lib/features/benefit_calculator/domain/repositories/. Use DateTime.toIso8601String() for toJson and DateTime.parse() for fromJson. The averageDurationMinutes field must be consistent with totalDurationMinutes / sessionCount — document this invariant but do not enforce it in the model (the aggregator service is responsible for correctness).
The DateRange class should validate that end is not before start in its constructor to catch configuration errors early. Keep the interface minimal — a single method — to preserve the interface segregation principle.
Testing Requirements
Unit tests in test/models/activity_summary_test.dart. Cover: construction, empty() factory produces zeros and valid DateTimes, copyWith partial override, equality, toJson produces ISO-8601 strings for DateTime fields, fromJson parses ISO-8601 back to DateTime correctly, fromJson with invalid date string throws FormatException. Separately verify DateRange construction. No integration tests for this task.
Supabase organisation configuration table may not yet have the five multiplier columns, requiring a migration. If the migration is not coordinated with other teams touching the same table, schema conflicts could delay delivery.
Mitigation & Contingency
Mitigation: Add multiplier columns in a dedicated, non-destructive ALTER TABLE migration script. Review the organisation config table schema with the backend team before writing the migration. Use nullable columns with defaults so existing rows are unaffected.
Contingency: If the migration cannot be deployed in time, stub the repository to return hardcoded default multiplier values from a local config file, allowing parallel development. Swap in the real Supabase fetch once the migration is live.
The ActivitySummaryAggregator depends on activity records already persisted in the database. For newly onboarded peer mentors with no activity history, the aggregator will return zero counts, which could make the calculator appear broken on first use.
Mitigation & Contingency
Mitigation: Design the pre-fill value object to distinguish between 'no data yet' and 'zero activities'. The calculator input panel should display empty inputs (not zero) when no history exists, with placeholder text guiding the user to enter values manually.
Contingency: If the distinction cannot be surfaced cleanly in the UI timeline, fall back to always showing empty inputs and document the manual-entry path as the primary UX until activity data accumulates.