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
This commit is contained in:
Yuyao Huang 2026-05-09 13:43:57 +08:00
parent 427f62acca
commit 0d148b694f
2 changed files with 7 additions and 2 deletions

2
app.py
View File

@ -347,7 +347,7 @@ def api_update_task_status(task_id):
doing_task = t doing_task = t
break break
if doing_task: 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() updates["start_time"] = datetime.now().isoformat()
else: else:
updates["start_time"] = None updates["start_time"] = None

View File

@ -209,7 +209,12 @@ def get_tasks_sorted(goal_id):
cur = conn.execute( cur = conn.execute(
"""SELECT * FROM tasks WHERE goal_id = ? AND status != 'done' """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,) (goal_id,)
) )
unfinished = [row_to_dict(r) for r in cur.fetchall()] unfinished = [row_to_dict(r) for r in cur.fetchall()]