You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
merge: fix: resolve streak metrics truncated by days parameter (#7941)
## Description
Fixes#7919
**Problem:**
When a user supplied the `days` parameter (e.g., `?days=30` to visually
slice the contribution graph), the calendar object was mutated *before*
the streak and monthly statistics were calculated. As a result, the
calculated `currentStreak` and `longestStreak` metrics were computed
only over the sliced subset, capping them at 30 days and ignoring any
historical streak continuation.
**Solution:**
1. Pre-calculated the user's streak stats (`fullStats`) and monthly
stats (`fullMonthlyStats`) using the full, unsliced calendar immediately
after fetching it.
2. In `versus` mode, calculated the comparator's streak stats
(`fullVersusStats`) on the full timezone-normalized calendars prior to
slicing.
3. Applied the `days` parameter slicing to the calendar arrays *after*
statistics were computed, so the visual graph reflects the sliced
timeframe while displaying the correct overall streak metrics.
4. Added a new unit test in `app/api/streak/route.test.ts` to assert
this behavior and prevent future regressions.
## Pillar
- [ ] 🎨 Pillar 1 — New Theme Design
- [ ] 📐 Pillar 2 — Geometric SVG Improvement
- [ ] 🕐 Pillar 3 — Timezone Logic Optimization
- [x] 🛠️ Other (Bug fix, refactoring, docs)
## Visual Preview
*No layout/visual changes to the SVG presets. Slicing with `?days=N`
continues to render the requested subset of days but now displays the
true, uncapped streak numbers inside the stats section.*
## Checklist before requesting a review:
- [x] I have read the `CONTRIBUTING.md` file.
- [x] I have tested these changes locally
(`localhost:3000/api/streak?user=YOUR_USERNAME`).
- [x] I have run `npm run format` and `npm run lint` locally and
resolved all errors (CI will fail otherwise).
- [x] My commits follow the Conventional Commits format (e.g.,
`feat(themes): ...`, `fix(calculate): ...`).
- [ ] I have updated `README.md` if I added a new theme or URL
parameter.
- [x] I have starred the repo.
- [x] I have made sure that i have only one commit to merge in this PR.
- [x] The SVG output matches the CommitPulse "premium quality" aesthetic
standard (no raw elements, smooth animations, correct fonts).
- [ ] (Recommended) I joined the CommitPulse Discord community for
contributor discussions, mentorship, and faster PR support.
0 commit comments