Logbook speedup (#18376)

* filter logbook results by entity_id prior to instantiating them

* include by default, pass pep8

* pass pylint

* use entityfilter, update tests
This commit is contained in:
Aleksandr Smirnov authored and Paulus Schoutsen committed 2018-11-19 10:36:00 +01:00
1 parent f241becf7f
commit 089a2f4e71
4 files changed
+112 -69

No files matched your search

+4 -3
View File
@@ -17,7 +17,7 @@ from homeassistant.helpers.json import JSONEncoder
# pylint: disable=invalid-name
Base = declarative_base()
SCHEMA_VERSION = 6
SCHEMA_VERSION = 7
_LOGGER = logging.getLogger(__name__)
@@ -71,7 +71,7 @@ class States(Base): # type: ignore
__tablename__ = 'states'
state_id = Column(Integer, primary_key=True)
domain = Column(String(64))
entity_id = Column(String(255))
entity_id = Column(String(255), index=True)
state = Column(String(255))
attributes = Column(Text)
event_id = Column(Integer, ForeignKey('events.event_id'), index=True)
@@ -86,7 +86,8 @@ class States(Base): # type: ignore
# Used for fetching the state of entities at a specific time
# (get_states in history.py)
Index(
'ix_states_entity_id_last_updated', 'entity_id', 'last_updated'),)
'ix_states_entity_id_last_updated', 'entity_id', 'last_updated'),
)
@staticmethod
def from_event(event):