Skip to content

Earn streak freezes after 7 consecutive days - #151

Merged
thomasluizon merged 3 commits into
mainfrom
feature/streak-freeze-earning
Apr 15, 2026
Merged

Earn streak freezes after 7 consecutive days#151
thomasluizon merged 3 commits into
mainfrom
feature/streak-freeze-earning

Conversation

@thomasluizon

Copy link
Copy Markdown
Owner

Summary

  • Streak freezes are now earned, not gifted. Every 7 consecutive days of activity banks +1 freeze, capped at 3 accumulated. Activation deducts from the bank and is also capped at 3 uses per calendar month.
  • User entity gains StreakFreezesAccumulated and LastFreezeAwardStreak with AwardStreakFreezeIfEligible / ConsumeStreakFreeze methods.
  • UserStreakService awards after recalculating the current streak.
  • ActivateStreakFreezeCommand rejects when bank is empty or monthly cap hit; error codes STREAK_FREEZE_NOT_AVAILABLE and new STREAK_FREEZE_MONTHLY_LIMIT.
  • StreakInfoResponse exposes streakFreezesAccumulated, daysUntilNextFreeze, freezesAvailableToUse, canEarnMore.
  • Migration AddStreakFreezeAccumulation adds the two int columns to Users.

Matches the frontend PR in orbit-ui-mobile (shared schema expects the new fields).

Test plan

  • Run migration locally, verify StreakFreezesAccumulated and LastFreezeAwardStreak columns exist on Users
  • dotnet test tests/Orbit.Application.Tests passes (38 streak-related tests, 1611 total)
  • POST /api/gamification/streak/freeze returns 400 when accumulated = 0
  • POST /api/gamification/streak/freeze returns 400 when monthly usage = 3
  • GET /api/gamification/streak returns the new fields with sane values across a 0/3/7/14-day streak progression

🤖 Generated with Claude Code

- Add StreakFreezesAccumulated + LastFreezeAwardStreak to User entity
  with AwardStreakFreezeIfEligible (max 3 banked) and ConsumeStreakFreeze
- Hook UserStreakService to award a freeze on every 7-day streak milestone
- Rewrite ActivateStreakFreezeCommand: reject when accumulated <= 0,
  reject when calendar-month usage hits max (3), consume from bank
- Extend StreakInfoResponse with accumulated count, daysUntilNextFreeze,
  freezesAvailableToUse, canEarnMore
- Migration AddStreakFreezeAccumulation adds the two int columns

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 19a5b2004c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/Orbit.Domain/Entities/User.cs Outdated
thomasluizon and others added 2 commits April 15, 2026 15:57
StreakInfoResponse and StreakFreezeResponse gained new fields
(StreakFreezesAccumulated and related) for the earning feature;
update the two test call sites so the build compiles.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SetStreakState only cleared LastFreezeAwardStreak when the recalculated
streak was exactly 0, but the recalc commonly jumps from a prior streak
(e.g., 14) directly to 1 when the user logs again after a missed day.
The stale marker then made AwardStreakFreezeIfEligible treat new 7-day
runs as already awarded and withhold freezes until the user surpassed
the previous milestone (21 instead of 7), and DaysUntilNextFreeze drifted
along with it. Trigger the reset whenever the new streak is lower than
the old one, which covers both 14 -> 0 and 14 -> 1 restarts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@thomasluizon
thomasluizon merged commit 4e13d2b into main Apr 15, 2026
3 checks passed
@thomasluizon
thomasluizon deleted the feature/streak-freeze-earning branch April 15, 2026 19:30
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant