fix(calculate): remove dead-code reassignment breaking streak grace-period check#7946
Open
PadmakarBagade wants to merge 1 commit into
Open
fix(calculate): remove dead-code reassignment breaking streak grace-period check#7946PadmakarBagade wants to merge 1 commit into
PadmakarBagade wants to merge 1 commit into
Conversation
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. |
Contributor
|
🚨 Hey @PadmakarBagade, the CI Pipeline is failing on this PR and it has been marked as 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 passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7894
Description
calculateStreak()inlib/calculate.tshad a dead-code bug: the grace-period gap check computed the correcttodayIndex(either-1if the gap exceededgrace, orlastIndexotherwise), but an unconditionaltodayIndex = 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
Files Changed
lib/calculate.ts— removed the dead-codetodayIndex = lastIndex;linelib/calculate.grace-period.test.ts— new regression testsTesting
npx vitest run lib/calculate— all calculate-suite tests pass (including the two new tests) alongside my change.lib/calculate.tsor streak logic) were confirmed to fail identically onmainbefore this change, so they are unrelated to this fix.Checklist
npm run lintlocally.