fix: handle datetime serialization in update_task and move endpoint
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user