kin: auto-commit after pipeline

This commit is contained in:
Gros Frumos 2026-03-17 14:34:16 +02:00
parent b6f40a6ace
commit 0346d50899
2 changed files with 159 additions and 14 deletions

View file

@ -958,7 +958,7 @@ def create_handoff(
def get_handoffs_for_task(conn: sqlite3.Connection, task_id: str) -> list[dict]:
"""Get all handoffs for a task ordered by creation time."""
rows = conn.execute(
"SELECT * FROM department_handoffs WHERE task_id = ? ORDER BY created_at",
"SELECT * FROM department_handoffs WHERE task_id = ? ORDER BY created_at, id ASC",
(task_id,),
).fetchall()
return _rows_to_list(rows)
@ -974,14 +974,14 @@ def get_last_handoff(
row = conn.execute(
"""SELECT * FROM department_handoffs
WHERE task_id = ? AND to_department = ?
ORDER BY created_at DESC LIMIT 1""",
ORDER BY created_at DESC, id DESC LIMIT 1""",
(task_id, to_department),
).fetchone()
else:
row = conn.execute(
"""SELECT * FROM department_handoffs
WHERE task_id = ?
ORDER BY created_at DESC LIMIT 1""",
ORDER BY created_at DESC, id DESC LIMIT 1""",
(task_id,),
).fetchone()
return _row_to_dict(row)