Use faster time compare in history and live logbook (#113897)

This commit is contained in:
J. Nick Koston 2024-03-20 13:40:23 -10:00 committed by GitHub
parent e9c1753f3a
commit 1e54595084
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -331,11 +331,14 @@ async def _async_events_consumer(
no_attributes: bool,
) -> None:
"""Stream events from the queue."""
subscriptions_setup_complete_timestamp = (
subscriptions_setup_complete_time.timestamp()
)
while True:
events: list[Event] = [await stream_queue.get()]
# If the event is older than the last db
# event we already sent it so we skip it.
if events[0].time_fired <= subscriptions_setup_complete_time:
if events[0].time_fired_timestamp <= subscriptions_setup_complete_timestamp:
continue
# We sleep for the EVENT_COALESCE_TIME so
# we can group events together to minimize

View File

@ -222,11 +222,14 @@ async def _async_events_consumer(
event_processor: EventProcessor,
) -> None:
"""Stream events from the queue."""
subscriptions_setup_complete_timestamp = (
subscriptions_setup_complete_time.timestamp()
)
while True:
events: list[Event] = [await stream_queue.get()]
# If the event is older than the last db
# event we already sent it so we skip it.
if events[0].time_fired <= subscriptions_setup_complete_time:
if events[0].time_fired_timestamp <= subscriptions_setup_complete_timestamp:
continue
# We sleep for the EVENT_COALESCE_TIME so
# we can group events together to minimize