fix: use SQLite-compatible space format in utcnow_iso(), fix credits ordering
utcnow_iso() now produces 'YYYY-MM-DD HH:MM:SS' (space separator) matching
SQLite's datetime('now') so lexicographic comparisons like
'published_at <= datetime(now)' work correctly.
Also add `id DESC` tiebreaker to get_ledger() ORDER BY to preserve
insertion order when multiple credits are added within the same second.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -199,6 +199,6 @@ async def get_ledger(supplier_id: int, limit: int = 50) -> list[dict]:
|
||||
FROM credit_ledger cl
|
||||
LEFT JOIN lead_forwards lf ON cl.reference_id = lf.id AND cl.event_type = 'lead_unlock'
|
||||
WHERE cl.supplier_id = ?
|
||||
ORDER BY cl.created_at DESC LIMIT ?""",
|
||||
ORDER BY cl.created_at DESC, cl.id DESC LIMIT ?""",
|
||||
(supplier_id, limit),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user