Skip to content

feat: add streak freeze feature (#37)#67

Merged
Priyanshu-byte-coder merged 8 commits into
Priyanshu-byte-coder:mainfrom
IshitaSingh0822:main
May 15, 2026
Merged

feat: add streak freeze feature (#37)#67
Priyanshu-byte-coder merged 8 commits into
Priyanshu-byte-coder:mainfrom
IshitaSingh0822:main

Conversation

@IshitaSingh0822
Copy link
Copy Markdown
Contributor

Summary

Adds streak freeze feature - lets users protect their streak for one day without breaking it.

Closes #37

Type of Change

  • New feature

Changes Made

  • Added supabase/migrations/20260515000000_add_streak_freezes.sql
  • Added GET and POST /api/streak/freeze endpoints
  • Updated GET /api/metrics/streak to treat freeze dates as active days
  • Updated StreakTracker.tsx to show freeze status and "Use Freeze" button

How to Test

  1. Run the migration in Supabase SQL Editor
  2. Sign in and go to dashboard
  3. Click "Use Freeze" in the Streak Tracker card
  4. Refresh — freeze status should persist

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

@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.

@IshitaSingh0822
Copy link
Copy Markdown
Contributor Author

Hey @Priyanshu-byte-coder, I have raised the PR for #37.
Please review when you get a chance!

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

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_at column name is misleading — it's set at insert time so it's really created_at. Not blocking, but worth renaming.
  • var(--control) used in StreakTracker.tsx — verify this CSS variable is defined in globals.css (the dark mode PR added --accent-soft and --accent but I don't see --control in 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.

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

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 Priyanshu-byte-coder added type:feature GSSoC type bonus: new feature level:advanced GSSoC: Advanced difficulty (55 pts) gssoc26 GSSoC 2026 contribution labels May 15, 2026
Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

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:

  1. Delete any spaces on otherwise blank lines — they must be completely empty
  2. 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.

@IshitaSingh0822
Copy link
Copy Markdown
Contributor Author

IshitaSingh0822 commented May 15, 2026

Hey @Priyanshu-byte-coder, both blockers have been fixed:

  1. package-lock.json reverted using upstream/main
  2. SQL migration trailing whitespace removed and EOF newline added

Could you please review when you get a chance?

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Owner

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Choose a reason for hiding this comment

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

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.

@Priyanshu-byte-coder Priyanshu-byte-coder merged commit 99b45c6 into Priyanshu-byte-coder:main May 15, 2026
1 check passed
@Priyanshu-byte-coder Priyanshu-byte-coder added the gssoc:approved GSSoC: PR approved for scoring label May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level:advanced GSSoC: Advanced difficulty (55 pts) type:feature GSSoC type bonus: new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Streak freeze — allow users to protect a streak day

2 participants