fix: convert datetime objects to ISO strings before JSON serialization in task history
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user