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

@@ -32,6 +32,9 @@ class SpotProvider:
# their infer_missing() method called to complete their data set. This is called by the API-querying
# subclasses on receiving spots.
def submit_batch(self, spots):
# Sort the batch so that earliest ones go in first. This helps keep the ordering correct when spots are fired
# off to SSE listeners.
spots = sorted(spots, key=lambda spot: (spot.time if spot and spot.time else 0))
for spot in spots:
if datetime.fromtimestamp(spot.time, pytz.UTC) > self.last_spot_time:
# Fill in any blanks and add to the list