mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 14:17:45 +00:00
Use faster time compare in history and live logbook (#113897)
This commit is contained in:
parent
e9c1753f3a
commit
1e54595084
@ -331,11 +331,14 @@ async def _async_events_consumer(
|
|||||||
no_attributes: bool,
|
no_attributes: bool,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Stream events from the queue."""
|
"""Stream events from the queue."""
|
||||||
|
subscriptions_setup_complete_timestamp = (
|
||||||
|
subscriptions_setup_complete_time.timestamp()
|
||||||
|
)
|
||||||
while True:
|
while True:
|
||||||
events: list[Event] = [await stream_queue.get()]
|
events: list[Event] = [await stream_queue.get()]
|
||||||
# If the event is older than the last db
|
# If the event is older than the last db
|
||||||
# event we already sent it so we skip it.
|
# 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
|
continue
|
||||||
# We sleep for the EVENT_COALESCE_TIME so
|
# We sleep for the EVENT_COALESCE_TIME so
|
||||||
# we can group events together to minimize
|
# we can group events together to minimize
|
||||||
|
@ -222,11 +222,14 @@ async def _async_events_consumer(
|
|||||||
event_processor: EventProcessor,
|
event_processor: EventProcessor,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Stream events from the queue."""
|
"""Stream events from the queue."""
|
||||||
|
subscriptions_setup_complete_timestamp = (
|
||||||
|
subscriptions_setup_complete_time.timestamp()
|
||||||
|
)
|
||||||
while True:
|
while True:
|
||||||
events: list[Event] = [await stream_queue.get()]
|
events: list[Event] = [await stream_queue.get()]
|
||||||
# If the event is older than the last db
|
# If the event is older than the last db
|
||||||
# event we already sent it so we skip it.
|
# 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
|
continue
|
||||||
# We sleep for the EVENT_COALESCE_TIME so
|
# We sleep for the EVENT_COALESCE_TIME so
|
||||||
# we can group events together to minimize
|
# we can group events together to minimize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user