Skip to content

fix: resolve streak metrics truncated by days parameter#7941

Open
Kritika200520 wants to merge 1 commit into
JhaSourav07:mainfrom
Kritika200520:main
Open

fix: resolve streak metrics truncated by days parameter#7941
Kritika200520 wants to merge 1 commit into
JhaSourav07:mainfrom
Kritika200520:main

Conversation

@Kritika200520

Copy link
Copy Markdown
Contributor

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
  • 🛠️ 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:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • 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.
  • I have starred the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • 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.

@vercel

vercel Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

@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 Aamod007 added mentor:Aamod007 level:intermediate Moderate complexity tasks type:bug Something isn't working as expected type:refactor Code changes that neither fix a bug nor add a feature labels Jul 10, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Hey @Kritika200520, this pull request has been inactive for 3 days. It will be automatically closed in 2 days if no further activity occurs.

If you are still working on this, please push your latest changes or leave a comment to keep it active.

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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 Aamod007 added the quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. label Jul 17, 2026

@Aamod007 Aamod007 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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.

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

Labels

level:intermediate Moderate complexity tasks mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:bug Something isn't working as expected type:refactor Code changes that neither fix a bug nor add a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Streak Metrics Capped/Truncated by days Parameter

2 participants