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.
This commit is contained in:
counterweight 2025-12-22 16:18:51 +01:00
parent b0d5d51a21
commit de12300593
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C

View file

@ -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}")