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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user