Skip to content

Fix streak to only update on actual practice activities#493

Open
mircealungu wants to merge 2 commits intomasterfrom
fix-streak-only-on-practice
Open

Fix streak to only update on actual practice activities#493
mircealungu wants to merge 2 commits intomasterfrom
fix-streak-only-on-practice

Conversation

@mircealungu
Copy link
Member

Summary

  • Fix bug where daily streak continued even when users didn't practice
  • Streak was updating on ANY authenticated API call (just opening app)
  • Now streak only updates when users actually practice (exercises, reading, listening, translations)
  • Added reset logic: streak resets to 0 if user hasn't practiced in 2+ days

Test plan

  • User opens app without practicing → streak should NOT increase
  • User hasn't practiced for 2+ days, opens app → streak shows 0
  • User completes exercise → streak increments
  • User starts reading an article → streak increments
  • User starts listening to audio → streak increments
  • User translates a word → streak increments

🤖 Generated with Claude Code

@github-actions
Copy link

github-actions bot commented Feb 26, 2026

ArchLens detected architectural changes in the following views:

Previously, the daily streak was updated on ANY authenticated API call
(via the @requires_session decorator), causing streaks to continue even
when users just opened the app without practicing.

Changes:
- Add reset_streak_if_broken() to UserLanguage - resets streak to 0 if
  user hasn't practiced in 2+ days (called on login)
- Change @requires_session to call reset_streak_if_broken() instead of
  update_streak_if_needed() - only resets broken streaks, doesn't increment
- Add update_user_streak() helper function for practice endpoints
- Add streak updates to actual practice endpoints:
  - /report_exercise_outcome (completing exercises)
  - /reading_session_start (starting to read)
  - /listening_session_start (starting to listen)
  - /get_one_translation (translating words while reading)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mircealungu mircealungu force-pushed the fix-streak-only-on-practice branch from 4dc3112 to 9f8d53d Compare February 26, 2026 15:43
if self.last_practiced.date() < yesterday:
self.daily_streak = 0
if session:
session.add(self)
Copy link
Member Author

Choose a reason for hiding this comment

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

@xXPinkmagicXx @klnyzzz33 @gabortodor -- folks, i know we'll have badges for streak lengths. but here, where we reset streaks - should we also save the longest streak? if it's between 50 and 100 it might still be nice to remember it?

i just had this brilliant idea of ... if we save streaks with from and two then we can do things like - auto-fusing streaks e.g. if you have a 50 day streak, it could automatically connect with another 50 day streak even if they're separate by a few days... :) i guess i'm overthinking things a bit... :)

Copy link

@klnyzzz33 klnyzzz33 Feb 27, 2026

Choose a reason for hiding this comment

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

I think the longest streak should definitely be saved, yes. It would be nice to show the user on their profile.

For the second part: wouldn't that be a bit misleading because then it's not a streak anymore, strictly speaking? How would we determine the tolerance, would it be always a few days between the streaks? But then I could abuse it, and only log in every 2nd or 3rd day, and still keep my streak going. Or would you only fuse large streaks together, like 50 days or above?

Saves max_streak and max_streak_date before resetting daily_streak,
so users can see their all-time best even after breaking a streak.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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.

2 participants