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 logging
import random import random
import time import time
from datetime import UTC, datetime
import asyncpg import asyncpg
from pgqueuer import Job, QueueManager, SchedulerManager 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 INSERT INTO price_history
(source, pair, price, timestamp, created_at) (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 ON CONFLICT (source, pair, timestamp) DO NOTHING
""", """,
SOURCE_BITFINEX, SOURCE_BITFINEX,
PAIR_BTC_EUR, PAIR_BTC_EUR,
price, price,
timestamp, timestamp,
datetime.now(UTC),
) )
logger.info(f"Fetched BTC/EUR price: €{price:.2f}") logger.info(f"Fetched BTC/EUR price: €{price:.2f}")