fix: handle datetime serialization in update_task and move endpoint
Deploy Dashboard (Dev) / deploy-dev (push) Failing after 16m16s
Run Tests / Backend Tests (push) Failing after 42s
Run Tests / Frontend Tests (push) Has started running
Run Tests / Test Summary (push) Has been cancelled

This commit is contained in:
Gan, Jimmy
2026-04-02 01:47:33 +08:00
parent 9f2cd7cab2
commit 1663535beb
2 changed files with 11 additions and 2 deletions
+10 -1
View File
@@ -365,11 +365,20 @@ async def update_task(
task = dict(row)
task["tags"] = json.loads(task["tags"]) if task["tags"] else []
# Convert datetime objects to ISO format strings for JSON serialization
old_values_for_history = old_values.copy()
updates_for_history = updates.copy()
for key in ["created_at", "updated_at", "completed_at", "due_date"]:
if old_values_for_history.get(key):
old_values_for_history[key] = old_values_for_history[key].isoformat()
if updates_for_history.get(key):
updates_for_history[key] = updates_for_history[key].isoformat()
# Log history
await conn.execute("""
INSERT INTO task_history (task_id, action, actor, actor_type, old_value, new_value)
VALUES ($1, $2, $3, $4, $5, $6)
""", task_id, "updated", actor, "human", json.dumps(old_values), json.dumps(updates))
""", task_id, "updated", actor, "human", json.dumps(old_values_for_history), json.dumps(updates_for_history))
return task