Skip to content

fix(stats): correct session coding time calculation and streak expiry - #34

Merged
Adnan9-63 merged 1 commit into
mainfrom
fix/stats-coding-time-and-streak-decay
Oct 21, 2026
Merged

Adnan9-63 merged 1 commit into
mainfrom
fix/stats-coding-time-and-streak-decay

Conversation

@Adnan9-63

Copy link
Copy Markdown
Member

Description

This PR resolves two core bugs in the stats and streak tracking engine:

  1. Fix double-counting of session coding time in \getSnapshot()\ (Fixes Fix double-counting of session coding time in getSnapshot() #22):

    • Previously, \StatsEngine.getSnapshot()\ added \ his.totalCodingMins + this.getSessionMinutes(). Because
      ecordCodingTime(1)\ already accumulates minutes in real time every 60 seconds, adding session minutes resulted in session time being counted twice.
    • Now returns \ otalCodingMins\ directly without inflating by wall-clock session time.
  2. Recalculate or clear inactive streak on startup (Fixes Recalculate or clear inactive streak on startup #24):

    • Previously, streaks were only evaluated when a file was saved or lines were typed. If a user had a 10-day streak and didn't code for 2 weeks, browsing files would still display \10-day streak.
    • Adds _checkStreakExpiry()\ on startup and snapshot computation. If 2 or more days have elapsed since \lastActiveDay, the active streak is cleanly reset to 0 while preserving \longestStreak.
  3. Added comprehensive unit test suite:

    • Added \ ests/stats.test.js\ with full test coverage for coding time accumulation, streak expiration after inactivity, and consecutive day continuation.
    • Added
      pm test\ to \package.json\ and CI workflow.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New unit tests (adds regression testing)

Copilot AI balanced review requested due to automatic review settings October 21, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@Adnan9-63
Adnan9-63 merged commit 3506424 into main Oct 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recalculate or clear inactive streak on startup Fix double-counting of session coding time in getSnapshot()

2 participants