feat(study): add review streak tracking and home indicator#172
feat(study): add review streak tracking and home indicator#172DevamPatel22 wants to merge 4 commits into
Conversation
Pairadux
left a comment
There was a problem hiding this comment.
Review
Looks good overall — nice work wiring up session summary persistence and the streak UI. Tests are solid with good edge case coverage, and the asOf parameter for testability is a nice touch.
Stale Streak Data
reviewStreakProvider is a plain FutureProvider that caches until explicitly invalidated. If the app stays open past midnight the streak won't refresh. Either switch to FutureProvider.autoDispose or invalidate on app lifecycle resume via WidgetsBindingObserver.didChangeAppLifecycleState.
getStreak Performance
getStreak() loads every distinct date into Dart and computes in memory. Fine for now, but the current streak could be a backwards SQL scan from today/yesterday and longest streak could use a window function. Worth a follow-up.
Pairadux
left a comment
There was a problem hiding this comment.
Both prior comments addressed thoroughly — autoDispose + day/resume refresh providers, and SQL-based streak computation with gap-and-islands. Tests cover all the right edges.
Left two nitpicks below as suggestions you can apply directly. The flame animation can stay as-is.
| SELECT COUNT(*) AS current_streak | ||
| FROM streak | ||
| WHERE EXISTS ( | ||
| SELECT 1 | ||
| FROM ${DatabaseConstants.tableReviewSessionSummary} | ||
| WHERE ${DatabaseConstants.colDate} = streak.day | ||
| AND ${DatabaseConstants.colTotalReviews} > 0 | ||
| ) |
There was a problem hiding this comment.
Minor: the outer WHERE EXISTS here never filters anything. Every row in the streak recursive CTE is added because the prior day's row exists, and the base case is the anchor day, which is guaranteed to exist by the has_today/has_yesterday check above. Safe to drop:
| SELECT COUNT(*) AS current_streak | |
| FROM streak | |
| WHERE EXISTS ( | |
| SELECT 1 | |
| FROM ${DatabaseConstants.tableReviewSessionSummary} | |
| WHERE ${DatabaseConstants.colDate} = streak.day | |
| AND ${DatabaseConstants.colTotalReviews} > 0 | |
| ) | |
| SELECT COUNT(*) AS current_streak | |
| FROM streak |
Co-authored-by: Austin Gause <dev@austingause.com>
Adds review streak tracking from completed study sessions and shows a live streak indicator on the home screen while keeping streak stats updated for current, longest, and last completed progress.