Personal Statistics BLoC
Component Detail
Description
BLoC state management unit for the personal peer mentor statistics view. Manages loading and display of individual mentor statistics and delegates fetching to PersonalStatsService.
personal-stats-bloc
Summaries
The Personal Statistics BLoC empowers individual peer mentors with clear visibility into their own contribution history, session counts, and performance trends over configurable time periods. By giving mentors ownership of their personal impact data, this component drives engagement and motivation — mentors who can see their progress are more likely to remain active participants. This self-service insight reduces the administrative burden on coordinators who would otherwise field individual progress queries. The result is a more autonomous, engaged mentor workforce that requires less hand-holding, contributing directly to program scalability and reduced coordinator workload costs.
Personal Statistics BLoC is rated low complexity with a single dependency on PersonalStatsService, making it a straightforward sprint item suitable for a junior-to-mid developer. The dependency chain is shallow: PersonalStatsService must be ready before integration work begins. Testing scope includes loading/loaded/error state transitions, period filter changes, and cache invalidation on activity registration events — all well-bounded scenarios. No shared state or cross-feature event coupling beyond the activity stream subscription introduces significant risk.
Delivery risk is low; the main scheduling consideration is ensuring PersonalStatsService and the activity event stream infrastructure are available in the same sprint or the one immediately prior.
PersonalStatsBloc follows the same BLoC 8.x pattern as CoordinatorStatsBloc but with reduced scope: it accepts a PersonalStatsService via constructor injection and handles three events — LoadPersonalStats(String mentorId, StatsPeriodFilter filter), ChangePersonalStatsPeriod(DateRange period), and RefreshPersonalStats(). State emissions are PersonalStatsLoading, PersonalStatsLoaded(PersonalStatsSummary), and PersonalStatsError(String message). The mentorId should be injected at BLoC construction or sourced from an auth provider to avoid passing it per-event. Cache invalidation on activity registration reuses the same stream subscription pattern as CoordinatorStatsBloc — consider abstracting the subscription logic into a shared mixin or base class to reduce duplication.
Ensure DateRange is equatable for correct period-change detection.
Responsibilities
- Manage loading / loaded / error states for personal stats view
- React to period filter changes
- Trigger cache invalidation on activity registration events
Interfaces
PersonalStatsBloc(PersonalStatsService personalStatsService)
LoadPersonalStats(String mentorId, StatsPeriodFilter filter)
ChangePersonalStatsPeriod(DateRange period)
RefreshPersonalStats()
PersonalStatsLoading
PersonalStatsLoaded(PersonalStatsSummary summary)
PersonalStatsError(String message)