Skip to content

Soft-delete streak goals and fix backdated start date bug#121

Open
anscg wants to merge 3 commits into
hackclub:mainfrom
anscg:fix/streak-goal-soft-delete
Open

Soft-delete streak goals and fix backdated start date bug#121
anscg wants to merge 3 commits into
hackclub:mainfrom
anscg:fix/streak-goal-soft-delete

Conversation

@anscg
Copy link
Copy Markdown
Collaborator

@anscg anscg commented Apr 22, 2026

Summary

  • Streak goals are now soft-deleted (via Discardable) instead of permanently destroyed when a user sets a new goal or their streak breaks — preserving history
  • Replaced the unique index on user_id with a partial index scoped to kept (non-discarded) records, allowing multiple historical goals per user
  • user.streak_goal association now scoped to .kept so it always returns the active goal
  • Fixed a bug where new goals were backdated to the start of the user's current streak, causing them to be immediately completable — new goals now always start from today

Root cause of the double-announcement bug (user 252)

Pegoku completed their 7-day goal on Apr 20, then immediately set a new 3-day goal. Because started_on was backdated to the streak start (Apr 14), the 3-day goal was already satisfied on creation. The next day when reconcile_missed_days ran a freeze and called check_goal_completion, it fired the announcement immediately.

@anscg anscg mentioned this pull request Apr 22, 2026
Closed
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