Files
habit-tracker/app/schemas/habit_log.py
T
shinalok 800f42eab1 add habit leveling/XP system, explicit fail marking for missed habits, and scrollable habit tabs
- Habits and the account now accumulate XP and levels from check streaks, with
  streak/level-up celebration banners and push notifications.
- The "yesterday missed" banner on /today now lets a habit be explicitly marked
  failed (not just checked done), backed by a new HabitLog.status column so
  completion-rate/streak calculations never count a failed day as done.
- The habit management tabs scroll horizontally on narrow screens instead of
  wrapping to two lines, with a pure-CSS edge shadow indicating more content.
2026-07-20 18:18:56 +09:00

50 lines
1.3 KiB
Python

from datetime import date, datetime
from pydantic import BaseModel, ConfigDict
from app.schemas.level import LevelInfo
class HabitLogOut(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
habit_id: int
log_date: date
checked_at: datetime
class TodayItem(BaseModel):
habit_id: int
name: str
habit_type: str
condition_text: str | None
reminder_time: str | None
checked: bool
completion_rate: float
current_streak: int
scheduled_days: int
level_info: LevelInfo
class MonthlySummaryDay(BaseModel):
log_date: date
scheduled_count: int
checked_count: int
class WeeklyMatrixRow(BaseModel):
habit_id: int
name: str
habit_type: str
checks: dict[str, bool | None] # ISO 날짜 문자열 -> 체크 여부 (None이면 그 요일에 예정되지 않음)
completion_rate: float # 이번 주, 오늘까지 지난 예정일 중 체크한 비율 (%)
class HabitStats(BaseModel):
completion_rate: float # 습관 생성일부터 오늘까지, 예정된 날 중 체크한 비율 (%)
current_streak: int # 오늘(또는 어제)부터 거슬러 올라가며 끊기지 않고 체크한 예정일 수
scheduled_days: int
checked_days: int
level_info: LevelInfo