From de123005930ce3c02f800cac48eff913fca2494a Mon Sep 17 00:00:00 2001 From: counterweight Date: Mon, 22 Dec 2025 16:18:51 +0100 Subject: [PATCH] fix: use Python datetime for created_at in worker Consistent with model default which uses datetime.now(UTC) rather than SQL NOW() for created_at field. --- backend/worker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/worker.py b/backend/worker.py index 2bc436e..d025dcf 100644 --- a/backend/worker.py +++ b/backend/worker.py @@ -5,6 +5,7 @@ import json import logging import random import time +from datetime import UTC, datetime import asyncpg from pgqueuer import Job, QueueManager, SchedulerManager @@ -116,13 +117,14 @@ async def process_bitcoin_price_job(db_pool: asyncpg.Pool) -> None: """ INSERT INTO price_history (source, pair, price, timestamp, created_at) - VALUES ($1, $2, $3, $4, NOW()) + VALUES ($1, $2, $3, $4, $5) ON CONFLICT (source, pair, timestamp) DO NOTHING """, SOURCE_BITFINEX, PAIR_BTC_EUR, price, timestamp, + datetime.now(UTC), ) logger.info(f"Fetched BTC/EUR price: €{price:.2f}")