Skip to content

fix(calculate): remove dead-code reassignment breaking streak grace-period check#7946

Open
PadmakarBagade wants to merge 1 commit into
JhaSourav07:mainfrom
PadmakarBagade:bugfix/streak-grace-period
Open

fix(calculate): remove dead-code reassignment breaking streak grace-period check#7946
PadmakarBagade wants to merge 1 commit into
JhaSourav07:mainfrom
PadmakarBagade:bugfix/streak-grace-period

Conversation

@PadmakarBagade

Copy link
Copy Markdown
Contributor

Fixes #7894

Description

calculateStreak() in lib/calculate.ts had a dead-code bug: the grace-period gap check computed the correct todayIndex (either -1 if the gap exceeded grace, or lastIndex otherwise), but an unconditional todayIndex = lastIndex; immediately after the if/else overwrote that result every time. This meant a user's streak was never reset even when their last recorded contribution was older than their grace period — the core streak feature could report an alive streak when it should have shown 0.

This PR removes the redundant line so the grace-period check actually takes effect, and adds a regression test covering both the "gap exceeds grace" (streak resets to 0) and "gap within grace" (streak stays alive) cases.

Type of Change

  • Other (Bug fix, refactoring, docs)

Files Changed

  • lib/calculate.ts — removed the dead-code todayIndex = lastIndex; line
  • lib/calculate.grace-period.test.ts — new regression tests

Testing

  • Ran npx vitest run lib/calculate — all calculate-suite tests pass (including the two new tests) alongside my change.
  • Ran the full suite; unrelated pre-existing failures observed (not touching lib/calculate.ts or streak logic) were confirmed to fail identically on main before this change, so they are unrelated to this fix.

Checklist

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally.
  • I have run formatting checks for the changed files and npm run lint locally.
  • My commit follows the Conventional Commits format.
  • I have updated README.md if I added a new theme or URL parameter. (N/A — no new theme or URL param)
  • I have starred the repo.
  • I have made sure that I have only one commit to merge in this PR.

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@PadmakarBagade is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jul 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🚨 Hey @PadmakarBagade, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:blocked This PR is blocked due to a failing CI check.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: streak grace-period check is dead code in calculateStreak() — redundant reassignment always overrides todayIndex

1 participant