feat: add streak freeze feature (#37)#67
Conversation
|
@IshitaSingh0822 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. |
|
Hey @Priyanshu-byte-coder, I have raised the PR for #37. |
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Thanks for implementing the streak freeze feature! The overall architecture is solid — migration, two API endpoints, UI component, and the streak calculation correctly merges freeze dates into daySet. A few things to fix before merge.
Blockers
1. Revert package-lock.json
The lockfile changes (removing "peer": true from ~10 packages) are npm-version noise unrelated to this feature. Please revert package-lock.json entirely — same issue flagged on previous PRs.
2. No unique constraint on (user_id, freeze_date)
The POST endpoint guards against duplicates in application code, but there's no DB-level constraint. Two rapid clicks can race past the check and insert two rows for the same date.
Add to the migration:
create unique index if not exists streak_freezes_user_date_uniq
on streak_freezes(user_id, freeze_date);3. Missing newline at end of file
Three files are missing a trailing newline: route.ts (streak), route.ts (freeze), StreakTracker.tsx, and the .sql migration. Most editors add this automatically — please fix.
Minor
used_atcolumn name is misleading — it's set at insert time so it's reallycreated_at. Not blocking, but worth renaming.var(--control)used inStreakTracker.tsx— verify this CSS variable is defined inglobals.css(the dark mode PR added--accent-softand--accentbut I don't see--controlin the diff).
Everything else — the parallel Promise.all fetches, loading states, error display, the handleUseFreeze refresh flow, and the migration indexes — looks clean. Fix the three blockers and this is ready.
…ines, revert lockfile
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Good progress — unique constraint via 23505 error code is actually cleaner than the pre-check I suggested, created_at rename done, .ts files have EOF newlines, unused NextRequest removed. Two things still outstanding.
Still blocking
1. package-lock.json not reverted
Still has "peer": true removed from 10 packages — same npm-version noise, flagged twice. Please run:
git checkout main -- package-lock.json
and commit just that revert.
2. SQL migration — trailing whitespace + missing EOF newline
Last line of the migration is a line containing only a space, and the file still has no trailing newline. Remove the blank line and add a newline after the closing ;.
Everything else looks good. Fix these two and this is ready to merge.
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Both blockers are still present — the commit message says they were fixed but the diff shows otherwise.
Still blocking (3rd request)
1. package-lock.json not reverted
The diff still shows 12 "peer": true deletions — identical to before. The revert did not work. Run this exact command:
git checkout origin/main -- package-lock.json
git add package-lock.json
git commit -m "fix: revert package-lock.json"
git push
Using origin/main (not local main) ensures you get the correct upstream version.
2. SQL migration — trailing whitespace + no EOF newline
The blank lines between SQL statements still contain a space character (shown as + in the diff). The file still ends with \ No newline at end of file.
Open supabase/migrations/20260515000000_add_streak_freezes.sql in your editor and:
- Delete any spaces on otherwise blank lines — they must be completely empty
- Make sure the last line (
on streak_freezes(user_id, freeze_date);) ends with a newline
Most editors have a "trim trailing whitespace on save" and "insert final newline" setting — enabling these will handle it automatically.
Everything else in this PR is solid. These two are the only things left.
|
Hey @Priyanshu-byte-coder, both blockers have been fixed:
Could you please review when you get a chance? |
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
Almost there — package-lock reverted and SQL migration is clean now. One thing left.
Still blocking
Merge conflict markers in StreakTracker.tsx
The file has unresolved conflict markers:
<<<<<<< HEAD
const [freezeLoading, setFreezeLoading] = useState(false);
...
=======
const [error, setError] = useState<string | null>(null);
...
>>>>>>> upstream/main
This will cause a build failure. You need to resolve the conflict — keep your freeze feature code (the HEAD section) and discard the conflicting lines from upstream. Then push again.
Priyanshu-byte-coder
left a comment
There was a problem hiding this comment.
All blockers resolved — package-lock reverted, migration is clean (no trailing whitespace, proper EOF newline, unique index on (user_id, freeze_date)), and the merge conflict in StreakTracker is gone.
The streak calculation correctly merges freeze dates into daySet so frozen days count as active. The GET/POST routes handle the unique constraint violation via 23505 error code. Solid backend implementation.
Note: the StreakTracker UI for applying/viewing freezes was lost during conflict resolution — that can come as a follow-up PR on top of this.
99b45c6
into
Priyanshu-byte-coder:main
Summary
Adds streak freeze feature - lets users protect their streak for one day without breaking it.
Closes #37
Type of Change
Changes Made
supabase/migrations/20260515000000_add_streak_freezes.sqlGETandPOST/api/streak/freezeendpointsGET /api/metrics/streakto treat freeze dates as active daysStreakTracker.tsxto show freeze status and "Use Freeze" buttonHow to Test
Checklist
npm run lintpasses locallynpm run type-check)