mirror of
https://github.com/home-assistant/core.git
synced 2026-09-27 01:46:11 -04:00
Optimize _get_states_with_session (#56734)
* Optimize _get_states_with_session * Move custom filters to derived table * Remove useless derived table * Filter old states after grouping * Split query * Add comments * Simplify state update period criteria * Only apply custom filters if we didn't get an include list of entities Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
co-authored by
J. Nick Koston
parent
daebc34f4d
commit
00651a4055
@@ -48,13 +48,24 @@ def test_get_states(hass_recorder):
|
||||
|
||||
wait_recording_done(hass)
|
||||
|
||||
# Get states returns everything before POINT
|
||||
# Get states returns everything before POINT for all entities
|
||||
for state1, state2 in zip(
|
||||
states,
|
||||
sorted(history.get_states(hass, future), key=lambda state: state.entity_id),
|
||||
):
|
||||
assert state1 == state2
|
||||
|
||||
# Get states returns everything before POINT for tested entities
|
||||
entities = [f"test.point_in_time_{i % 5}" for i in range(5)]
|
||||
for state1, state2 in zip(
|
||||
states,
|
||||
sorted(
|
||||
history.get_states(hass, future, entities),
|
||||
key=lambda state: state.entity_id,
|
||||
),
|
||||
):
|
||||
assert state1 == state2
|
||||
|
||||
# Test get_state here because we have a DB setup
|
||||
assert states[0] == history.get_state(hass, future, states[0].entity_id)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user