Refactor streak modal into a single card with top border-b iframe animation and bottom greetings, daily check-in Snapchat-like streak update/reset logic

This commit is contained in:
2026-07-10 14:29:34 +05:30
parent 96cf5f6dc1
commit 89c704c02c
5 changed files with 109 additions and 45 deletions

View File

@@ -480,6 +480,34 @@ def get_user_profile(user_id: UUID, session: Session = Depends(get_session)):
user = session.get(models.User, user_id)
if not user:
raise HTTPException(status_code=404, detail="User not found")
# Snapchat-style daily active streak check
now = datetime.utcnow()
today = now.date()
last_active_date = user.last_active.date()
delta = (today - last_active_date).days
changed = False
if user.streak_count == 0:
user.streak_count = 1
user.longest_streak = max(user.longest_streak, 1)
user.last_active = now
changed = True
elif delta == 1:
user.streak_count += 1
user.longest_streak = max(user.longest_streak, user.streak_count)
user.last_active = now
changed = True
elif delta > 1:
user.streak_count = 1
user.last_active = now
changed = True
if changed:
session.add(user)
session.commit()
session.refresh(user)
return user
class UserUpdate(BaseModel):