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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 76 additions and 34 deletions

View file

@ -1,5 +1,4 @@
"""Test HomeKit initialization."""
from homeassistant import core as ha
from homeassistant.components import logbook
from homeassistant.components.homekit.const import (
ATTR_DISPLAY_NAME,
@ -11,6 +10,7 @@ from homeassistant.const import ATTR_ENTITY_ID, ATTR_SERVICE
from homeassistant.setup import async_setup_component
from tests.async_mock import patch
from tests.components.logbook.test_init import MockLazyEventPartialState
async def test_humanify_homekit_changed_event(hass, hk_driver):
@ -22,7 +22,7 @@ async def test_humanify_homekit_changed_event(hass, hk_driver):
logbook.humanify(
hass,
[
ha.Event(
MockLazyEventPartialState(
EVENT_HOMEKIT_CHANGED,
{
ATTR_ENTITY_ID: "lock.front_door",
@ -30,7 +30,7 @@ async def test_humanify_homekit_changed_event(hass, hk_driver):
ATTR_SERVICE: "lock",
},
),
ha.Event(
MockLazyEventPartialState(
EVENT_HOMEKIT_CHANGED,
{
ATTR_ENTITY_ID: "cover.window",