Fix issue with SSE queues getting lost #3

This commit is contained in:
Ian Renton
2025-12-23 21:26:39 +00:00
parent 86beb27ebf
commit 6116d19580
3 changed files with 25 additions and 2 deletions

View File

@@ -30,6 +30,9 @@ class AlertProvider:
# because alerts could be created at any point for any time in the future. Rely on hashcode-based id matching
# to deal with duplicates.
def submit_batch(self, alerts):
# Sort the batch so that earliest ones go in first. This helps keep the ordering correct when alerts are fired
# off to SSE listeners.
alerts = sorted(alerts, key=lambda alert: (alert.start_time if alert and alert.start_time else 0))
for alert in alerts:
# Fill in any blanks and add to the list
alert.infer_missing()