fix: limit recommendation poll to 50 per cycle to prevent 85k-rec processing stall, add poll logging
This commit is contained in:
@@ -584,11 +584,21 @@ class TradingEngine:
|
||||
"WHERE action IN ('buy','sell') "
|
||||
"AND mode IN ('paper_eligible','live_eligible') "
|
||||
"AND generated_at > $1 "
|
||||
"ORDER BY confidence DESC",
|
||||
"ORDER BY confidence DESC "
|
||||
"LIMIT 50",
|
||||
self._last_poll_timestamp,
|
||||
)
|
||||
self._last_poll_timestamp = datetime.now(tz=timezone.utc)
|
||||
if rows:
|
||||
# Advance timestamp to the oldest rec in this batch
|
||||
# so next poll picks up where we left off
|
||||
last_gen = max(r["generated_at"] for r in rows)
|
||||
self._last_poll_timestamp = last_gen
|
||||
recs = [dict(r) for r in rows]
|
||||
if recs:
|
||||
logger.info(
|
||||
"Polled %d recommendations (highest confidence=%.3f)",
|
||||
len(recs), recs[0].get("confidence", 0),
|
||||
)
|
||||
except Exception:
|
||||
logger.debug("Could not poll recommendations — table may not exist yet")
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user