diff --git a/app.py b/app.py index d0660b5..264db69 100644 --- a/app.py +++ b/app.py @@ -347,7 +347,7 @@ def api_update_task_status(task_id): doing_task = t break if doing_task: - database.update_task(doing_task["id"], status="todo") + database.update_task(doing_task["id"], status="pending") updates["start_time"] = datetime.now().isoformat() else: updates["start_time"] = None diff --git a/database.py b/database.py index 13db531..d84a33f 100644 --- a/database.py +++ b/database.py @@ -209,7 +209,12 @@ def get_tasks_sorted(goal_id): cur = conn.execute( """SELECT * FROM tasks WHERE goal_id = ? AND status != 'done' - ORDER BY "order" ASC""", + ORDER BY CASE status + WHEN 'doing' THEN 1 + WHEN 'pending' THEN 2 + WHEN 'todo' THEN 3 + ELSE 4 + END, "order" ASC""", (goal_id,) ) unfinished = [row_to_dict(r) for r in cur.fetchall()]