Fix streak to only update on actual practice activities#493
Fix streak to only update on actual practice activities#493mircealungu wants to merge 2 commits intomasterfrom
Conversation
|
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>
4dc3112 to
9f8d53d
Compare
| if self.last_practiced.date() < yesterday: | ||
| self.daily_streak = 0 | ||
| if session: | ||
| session.add(self) |
There was a problem hiding this comment.
@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... :)
There was a problem hiding this comment.
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>
Summary
Test plan
🤖 Generated with Claude Code