From 0d148b694fe3ef20099475ecb1f01b6fdface0d2 Mon Sep 17 00:00:00 2001 From: Yuyao Huang Date: Sat, 9 May 2026 13:43:57 +0800 Subject: [PATCH] fix: change DOING takeover behavior to PENDING and enforce status sort order - When setting a new task to DOING, the previous DOING task now switches to PENDING instead of TODO - Task display order now prioritizes by status: DONE < DOING < PENDING < TODO, with order field respected within each status group --- app.py | 2 +- database.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) 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()]