add abandoned status to distinguish given-up habits from completed ones

Completed and abandoned habits were both lumped under a single terminal
state, making it impossible to tell "finished successfully" apart from
"gave up" when reviewing habit history.
This commit is contained in:
2026-07-17 20:19:35 +09:00
parent d0dd530e26
commit 55918d56d1
11 changed files with 167 additions and 3 deletions
+9
View File
@@ -79,9 +79,18 @@ def complete_habit(db: Session, habit: Habit) -> Habit:
return habit
def abandon_habit(db: Session, habit: Habit) -> Habit:
habit.status = HabitStatus.ABANDONED
habit.abandoned_at = datetime.now()
db.commit()
db.refresh(habit)
return habit
def reactivate_habit(db: Session, habit: Habit) -> Habit:
habit.status = HabitStatus.ACTIVE
habit.completed_at = None
habit.abandoned_at = None
db.commit()
db.refresh(habit)
return habit