[Fix] #1312 Streak logic duplication resolved.#1876
Conversation
|
@palxsh01 is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
|
Hey @palxsh01! Saw your work on GSSoC 2026. We are building TermUI, a TypeScript terminal UI framework with React-style hooks and JSX, rendered entirely in the terminal. We have 99 unassigned GSSoC issues open, including test coverage tasks across the packages. Your TypeScript background transfers directly. Karanjot, TermUI maintainer |
|
This PR has merge conflicts with git fetch origin
git rebase origin/main
git push --force-with-lease |
…ore logic abstracted to src/lib/streak.ts.
|
Hi @Priyanshu-byte-coder, |
e2a5d08
into
Priyanshu-byte-coder:main
|
🎉 Merged! Thanks for contributing to DevTrack. If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers. Keep an eye on open issues for your next contribution! |
Summary
Extracts the duplicated streak calculation algorithm into a single shared module
at
src/lib/streak.ts, removing ~230 lines of copy-pasted logic spread across6 source files. Also fixes two silent bugs uncovered during the consolidation.
Closes #1312
Type of Change
Changes Made
src/lib/streak.tsexposing two shared exports:calculateStreakFromDates(activeDates, freezeDates?)— full calculation with freeze date supportcalculateCurrentStreak(dates)— lightweight wrapper returning only the current streak numberstreak/route.ts,streak-shield/route.ts,public-profile-data.ts,compare/route.ts,leaderboard/route.ts,weekly-summary/route.tscalculateStreakFromDates.test.tsandleaderboard-streak.test.tsto import from the shared module instead of maintaining local copiescompare/route.tswherelongestStreakwas never tracked — endpoint returned only current streakstreak-shield/route.tswheredateDiffDaysusedDate.UTC()instead of ISO string truncation, causing off-by-one results for users near UTC midnightHow to Test
npm run type-check— should pass with no errorsnpm test— all 285 tests should passnpm run lint— should pass/api/metrics/streak,/api/badge/streak-shield, and/api/public/[username]return consistent streak values for the same GitHub userScreenshots (if UI change)
N/A — backend refactor only, no UI changes.
Checklist
npm run lintpasses locallynpm run type-check)Accessibility Checklist
Additional Notes
All existing tests continue to pass (285/285). All merge conflicts have been resolved, ready for a clean merge and PR.