1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 12:59:34 +00:00

Only process logbook timestamps for events we will keep (#36792)

* Only process logbook timestamps for events we will keep

Since we group by minute we were previously processing
every timestamp. We can avoid this by making all the
minute checks use the unprocessed datetime since
the groupings will be the same regardless of timezone.

This reduces the number of datetime object recreations
by at least an order of magnitude.
This commit is contained in:
J. Nick Koston
2020-06-15 14:54:20 -05:00
committed by GitHub
parent b0163b65c6
commit 0a219081ea
6 changed files with 76 additions and 34 deletions

View File

@@ -1,9 +1,10 @@
"""Tests for alexa."""
from homeassistant.components import logbook
from homeassistant.components.alexa.const import EVENT_ALEXA_SMART_HOME
import homeassistant.core as ha
from homeassistant.setup import async_setup_component
from tests.components.logbook.test_init import MockLazyEventPartialState
async def test_humanify_alexa_event(hass):
"""Test humanifying Alexa event."""
@@ -14,11 +15,11 @@ async def test_humanify_alexa_event(hass):
logbook.humanify(
hass,
[
ha.Event(
MockLazyEventPartialState(
EVENT_ALEXA_SMART_HOME,
{"request": {"namespace": "Alexa.Discovery", "name": "Discover"}},
),
ha.Event(
MockLazyEventPartialState(
EVENT_ALEXA_SMART_HOME,
{
"request": {
@@ -28,7 +29,7 @@ async def test_humanify_alexa_event(hass):
}
},
),
ha.Event(
MockLazyEventPartialState(
EVENT_ALEXA_SMART_HOME,
{
"request": {