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.
This commit is contained in:
2026-07-20 18:18:56 +09:00
parent 4a7ef5cc29
commit 800f42eab1
18 changed files with 665 additions and 42 deletions
+36
View File
@@ -0,0 +1,36 @@
from app.services import level_service
def test_level_from_xp_zero_is_level_one():
info = level_service.level_from_xp(0)
assert info.level == 1
assert info.xp_into_level == 0
assert info.xp_for_next_level == 20
assert info.progress_pct == 0.0
def test_level_from_xp_just_below_threshold_stays_at_level():
info = level_service.level_from_xp(19)
assert info.level == 1
assert info.xp_into_level == 19
assert info.progress_pct == 95.0
def test_level_from_xp_at_threshold_advances_level():
info = level_service.level_from_xp(20)
assert info.level == 2
assert info.xp_into_level == 0
assert info.xp_for_next_level == 30 # 레벨2->3 요구치는 레벨1->2보다 커진다(점점 완만해짐)
def test_level_from_xp_requirement_grows_with_level():
# Lv1->2: 20xp, Lv2->3: 30xp, Lv3->4: 40xp (누적 90xp에서 Lv4 도달)
info = level_service.level_from_xp(90)
assert info.level == 4
assert info.xp_into_level == 0
def test_level_from_xp_negative_floors_to_zero():
info = level_service.level_from_xp(-50)
assert info.level == 1
assert info.xp == 0