diff --git a/frontend/public/js/stats.js b/frontend/public/js/stats.js index 97bf442..75f94c8 100644 --- a/frontend/public/js/stats.js +++ b/frontend/public/js/stats.js @@ -56,9 +56,15 @@ export function completedSet(completions, user, goalId) { */ export function currentStreak(completedSetForUser, goal, refISO = todayISO()) { const start = goal.start_date; - const end = clampWindowEnd(goal, refISO); + let end = clampWindowEnd(goal, refISO); if (refISO < start) return 0; + // If today isn't completed yet and the goal is still active, + // start from yesterday — the day isn't over so don't break the streak. + if (end === refISO && !completedSetForUser.has(end)) { + end = addDays(end, -1); + } + let cur = end; let n = 0; while (cur >= start && completedSetForUser.has(cur)) {