Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/codegate/db/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,18 @@ async def record_alerts(self, alerts: List[Alert], initial_id: Optional[str]) ->
except Exception as e:
logger.error(f"Failed to record alert: {alert}.", error=str(e))

critical_alert_timestamp = None
recorded_alerts = []
for alert_coro in alerts_tasks:
alert_result = alert_coro.result()
recorded_alerts.append(alert_result)
if alert_result and alert_result.trigger_category == "critical":
await alert_queue.put(f"New alert detected: {alert.timestamp}")
critical_alert_timestamp = alert.timestamp

# only alert once per request and not once per critical alert.
if critical_alert_timestamp:
await alert_queue.put(f"New alert detected: {critical_alert_timestamp}")

# Uncomment to debug the recorded alerts
# logger.debug(f"Recorded alerts: {recorded_alerts}")
return recorded_alerts
Expand Down