WIP: [component/recorder] Refactoring & better handling of SQLAlchemy Sessions (#5607)

* Refactor recorder and Sessions

* Cover #4352

* NO_reset_on_return

* contextmanager

* coverage
This commit is contained in:
Johann Kellerman
2017-02-08 07:47:41 +02:00
committed by Paulus Schoutsen
parent bdebe5d53c
commit 490ef6afad
3 changed files with 221 additions and 153 deletions

View File

@@ -64,7 +64,7 @@ def get_significant_states(start_time, end_time=None, entity_id=None,
"""
entity_ids = (entity_id.lower(), ) if entity_id is not None else None
states = recorder.get_model('States')
query = recorder.query('States').filter(
query = recorder.query(states).filter(
(states.domain.in_(SIGNIFICANT_DOMAINS) |
(states.last_changed == states.last_updated)) &
(states.last_updated > start_time))