diff --git a/dashboard/backend/db/opc_db.py b/dashboard/backend/db/opc_db.py index 8b0dc00..147a222 100644 --- a/dashboard/backend/db/opc_db.py +++ b/dashboard/backend/db/opc_db.py @@ -258,11 +258,17 @@ async def create_task( task = dict(row) task["tags"] = json.loads(task["tags"]) if task["tags"] else [] + # Convert datetime objects to ISO format strings for JSON serialization + task_for_history = task.copy() + for key in ["created_at", "updated_at", "completed_at", "due_date"]: + if task_for_history.get(key): + task_for_history[key] = task_for_history[key].isoformat() + # Log history await conn.execute(""" INSERT INTO task_history (task_id, action, actor, actor_type, new_value) VALUES ($1, $2, $3, $4, $5) - """, task["id"], "created", actor, "human", json.dumps(task)) + """, task["id"], "created", actor, "human", json.dumps(task_for_history)) return task