add habit goal-period difficulty and habit formation research notes

Ground the 21-day habit myth in actual research (Lally et al. 2010) and let
users pick a target period (21/66/254 days or unlimited) matching that
study's easy/median/hard automaticity timelines when creating a habit,
with progress shown on the habits list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-19 10:12:17 +09:00
co-authored by Claude Sonnet 5
parent 55918d56d1
commit d212451fe0
15 changed files with 355 additions and 9 deletions
+16 -1
View File
@@ -1,7 +1,7 @@
import pytest
from pydantic import ValidationError
from app.models.habit import ALL_WEEKDAYS_MASK, HabitType
from app.models.habit import ALL_WEEKDAYS_MASK, HabitDifficulty, HabitType
from app.schemas.habit import HabitCreate
@@ -49,3 +49,18 @@ def test_weekdays_mask_single_day_accepted():
def test_weekdays_mask_defaults_to_all_days():
habit = HabitCreate(**_base_kwargs())
assert habit.weekdays_mask == ALL_WEEKDAYS_MASK
def test_difficulty_defaults_to_medium():
habit = HabitCreate(**_base_kwargs())
assert habit.difficulty == HabitDifficulty.MEDIUM
def test_difficulty_accepts_explicit_value():
habit = HabitCreate(**_base_kwargs(difficulty=HabitDifficulty.UNLIMITED))
assert habit.difficulty == HabitDifficulty.UNLIMITED
def test_difficulty_rejects_invalid_value():
with pytest.raises(ValidationError):
HabitCreate(**_base_kwargs(difficulty="impossible"))