Skip to content

Bug: Reading Streak Resets to 0 If User Hasn't Read Today #89

@HunarBhatia

Description

@HunarBhatia

Bug: Reading Streak Resets to 0 If User Hasn't Read Today

Describe the bug
The reading streak always shows 0 if the user hasn't logged a session yet today, even if they've read every single day for weeks prior.

Root Cause
In apps/web/src/pages/Stats.jsx, the getReadingStreak() function (line 315) compares dates[i] against today - i days starting from offset 0. So if the user hasn't read today, the very first comparison fails and the loop breaks immediately — returning 0.

Steps to Reproduce

  1. Log reading sessions consistently for several days in a row
  2. On a new day, open the Stats page before logging any session
  3. The streak displays 0 despite the consecutive reading history

Expected Behavior
The streak should remain intact if the user read yesterday. A grace window counting streaks ending on either today or yesterday is the standard behavior (used by Duolingo, Streaks, etc.) and gives users until end-of-day to maintain their streak.

Suggested Fix
In getReadingStreak(), check whether the most recent reading date is today or yesterday before starting the loop, and adjust the offset accordingly:

const startOffset = dates[0] === new Date().toDateString() ? 0 : 1;
for (let i = 0; i < dates.length; i++) {
    const expectedDate = new Date();
    expectedDate.setDate(expectedDate.getDate() - (i + startOffset));
    if (dates[i] === expectedDate.toDateString()) streak++;
    else break;
}

File affected
apps/web/src/pages/Stats.jsxgetReadingStreak() around line 315

I am a GSSoC 2026 contributor and would love to work on this issue.

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