fix: resolve streak metrics truncated by days parameter#7941
fix: resolve streak metrics truncated by days parameter#7941Kritika200520 wants to merge 1 commit into
Conversation
|
@Kritika200520 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
Aamod007
left a comment
There was a problem hiding this comment.
Hello! Thanks for your contribution to resolve the streak metrics truncation. I reviewed your changes in the API route where you refactored the data flow to use \ullStats\ and \ullWeekdayStats\ instead of recalculating. I also noticed some unrelated changes to \�pp/reviewform/page.tsx\ regarding handle normalization.
However, I see that multiple CI checks are currently failing, including the main Build and Test workflows. Because of these failing checks, I'm requesting changes. Please resolve the build errors locally and update the branch. You might also consider separating the review form changes into another PR to keep this one scoped!
Labels assigned:
- \level:intermediate: Modifying the core metrics data passing and API routing requires a solid understanding of the flow.
- \ ype:bug: Addresses metrics truncation.
- \ ype:refactor: Refactors how stats are provided to the SVG generators.
|
If you are still working on this, please push your latest changes or leave a comment to keep it active. |
Aamod007
left a comment
There was a problem hiding this comment.
Calculating the full, unsliced statistics before applying the \days\ parameter is the correct approach to fix the truncation bug. However, the build is currently failing (Lint / Typecheck / Test and Production Build). Please resolve these failures so I can approve this.
Aamod007
left a comment
There was a problem hiding this comment.
Fixing the streak metrics truncation in route.ts by adjusting the days parameter makes the stats much more accurate. However, the CI checks are failing. Please resolve the issues and rerun the CI pipeline.
Description
Fixes #7919
Problem:
When a user supplied the
daysparameter (e.g.,?days=30to visually slice the contribution graph), the calendar object was mutated before the streak and monthly statistics were calculated. As a result, the calculatedcurrentStreakandlongestStreakmetrics were computed only over the sliced subset, capping them at 30 days and ignoring any historical streak continuation.Solution:
fullStats) and monthly stats (fullMonthlyStats) using the full, unsliced calendar immediately after fetching it.versusmode, calculated the comparator's streak stats (fullVersusStats) on the full timezone-normalized calendars prior to slicing.daysparameter slicing to the calendar arrays after statistics were computed, so the visual graph reflects the sliced timeframe while displaying the correct overall streak metrics.app/api/streak/route.test.tsto assert this behavior and prevent future regressions.Pillar
Visual Preview
No layout/visual changes to the SVG presets. Slicing with
?days=Ncontinues to render the requested subset of days but now displays the true, uncapped streak numbers inside the stats section.Checklist before requesting a review:
CONTRIBUTING.mdfile.localhost:3000/api/streak?user=YOUR_USERNAME).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter.