Skip to content

Statistics data layer #150

Open
Open

Description

@MessiasLima

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

  • GIVEN the StatisticsRepository is initialized
    WHEN the free statistics are collected
    THEN they include total tasks created, total tasks completed, current streak, and longest streak
  • GIVEN the StatisticsRepository is initialized
    WHEN 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
  • GIVEN a user completes a task today
    AND they completed at least one task yesterday
    WHEN the current streak is computed
    THEN the streak increments by 1
  • GIVEN a user completes a task today
    AND they did not complete any task yesterday
    WHEN the current streak is computed
    THEN the streak resets to 1
  • GIVEN the current streak is longer than the previously stored longest streak
    WHEN the statistics are computed
    THEN the longest streak is updated
  • GIVEN the user is not a premium subscriber
    WHEN free statistics are requested
    THEN all free statistics are returned
  • GIVEN the user is a premium subscriber
    WHEN statistics are requested
    THEN both free and premium statistics are returned
  • GIVEN the StatisticsRepository is injected via Koin
    WHEN a ViewModel needs statistics
    THEN it can access them via StatisticsRepository.getStatistics(): Flow<Statistics>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions