Skip to content

Commit

Permalink
Perform logbook filtering on the worker thread (home-assistant#11161)
Browse files Browse the repository at this point in the history
  • Loading branch information
emlove authored and balloob committed Dec 16, 2017
1 parent 3d5d902 commit c4d71e9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions homeassistant/components/logbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ def get(self, request, datetime=None):
hass = request.app['hass']

events = yield from hass.async_add_job(
_get_events, hass, start_day, end_day)
events = _exclude_events(events, self.config)
return self.json(humanify(events))
_get_events, hass, self.config, start_day, end_day)
return self.json(events)


class Entry(object):
Expand Down Expand Up @@ -274,7 +273,7 @@ def humanify(events):
entity_id)


def _get_events(hass, start_day, end_day):
def _get_events(hass, config, start_day, end_day):
"""Get events for a period of time."""
from homeassistant.components.recorder.models import Events
from homeassistant.components.recorder.util import (
Expand All @@ -285,7 +284,8 @@ def _get_events(hass, start_day, end_day):
Events.time_fired).filter(
(Events.time_fired > start_day) &
(Events.time_fired < end_day))
return execute(query)
events = execute(query)
return humanify(_exclude_events(events, config))


def _exclude_events(events, config):
Expand Down

0 comments on commit c4d71e9

Please sign in to comment.