Description
Create the data layer for task statistics. This includes defining the statistics domain model and a repository that computes statistics from the task data stored in Room.
Free statistics include:
- Total tasks created
- Total tasks completed
- Current streak: number of consecutive days with at least one task completed
- Longest streak: the longest consecutive-day completion streak ever achieved
Premium statistics (gated behind #130) include:
- Completion rate (percentage of tasks completed)
- Average tasks completed per day over the last 7 days
- Most productive day of the week
- Tasks completed by priority breakdown
The StatisticsRepository exposes these as Flow<Statistics> so that UI screens can observe them reactively.
Depends on #120 (Task domain model and data layer), #130 (Premium gating infrastructure).
Scope
In scope: Statistics data class, StatisticsRepository interface and implementation, Room queries to compute statistics, free vs. premium statistics separation, and unit tests.
Out of scope: statistics UI screen (separate ticket #26).
Acceptance criteria
Description
Create the data layer for task statistics. This includes defining the statistics domain model and a repository that computes statistics from the task data stored in Room.
Free statistics include:
Premium statistics (gated behind #130) include:
The
StatisticsRepositoryexposes these asFlow<Statistics>so that UI screens can observe them reactively.Depends on #120 (Task domain model and data layer), #130 (Premium gating infrastructure).
Scope
In scope:
Statisticsdata class,StatisticsRepositoryinterface and implementation, Room queries to compute statistics, free vs. premium statistics separation, and unit tests.Out of scope: statistics UI screen (separate ticket #26).
Acceptance criteria
StatisticsRepositoryis initializedWHEN the free statistics are collected
THEN they include total tasks created, total tasks completed, current streak, and longest streak
StatisticsRepositoryis initializedWHEN the premium statistics are collected
THEN they include completion rate, average tasks completed per day (last 7 days), most productive day of the week, and tasks completed by priority breakdown
AND they completed at least one task yesterday
WHEN the current streak is computed
THEN the streak increments by 1
AND they did not complete any task yesterday
WHEN the current streak is computed
THEN the streak resets to 1
WHEN the statistics are computed
THEN the longest streak is updated
WHEN free statistics are requested
THEN all free statistics are returned
WHEN statistics are requested
THEN both free and premium statistics are returned
StatisticsRepositoryis injected via KoinWHEN a ViewModel needs statistics
THEN it can access them via
StatisticsRepository.getStatistics(): Flow<Statistics>