Avoid multiple round trips to the database for history API calls (#91193)
* delete more code * tweak * tweak * wrappers * restore lost performance * restore lost performance * restore lost performance * compact * reduce * fix refactor * DRY * tweak * delete the start time state injector * move away the legacy code * tweak * adjust * adjust * tweak * ignore impossible * fix a bug where the first start was changed to the start time when there was no previous history recorded before * avoid the empty scan most cases * postgresql * fixes * workaround for mariadb < 10.4 * remove unused * remove unused * adjust * bail early * tweak * tweak * fix more tests * fix recorderrun being init in the future in the test * run history tests on schema 30 as well * Revert "run history tests on schema 30 as well" This reverts commitd798b100ac
. * reduce * cleanup * tweak * reduce * prune * adjust * adjust * adjust * reverse later is faster because the index is in forward order and the data size we are reversing is much smaller even if we are in python code * Revert "reverse later is faster because the index is in forward order and the data size we are reversing is much smaller even if we are in python code" This reverts commitbf974e103e
. * fix test * Revert "Revert "reverse later is faster because the index is in forward order and the data size we are reversing is much smaller even if we are in python code"" This reverts commit119354499e
. * more coverage * adjust * fix for table order * impossible for it to be missing * remove some more legacy from the all states
This commit is contained in:
parent
7f62ed15fa
commit
4e6937d20f
13 changed files with 891 additions and 427 deletions
|
@ -130,13 +130,16 @@ def test_get_significant_states_with_initial(hass_history) -> None:
|
|||
"""
|
||||
hass = hass_history
|
||||
zero, four, states = record_states(hass)
|
||||
one = zero + timedelta(seconds=1)
|
||||
one_and_half = zero + timedelta(seconds=1.5)
|
||||
for entity_id in states:
|
||||
if entity_id == "media_player.test":
|
||||
states[entity_id] = states[entity_id][1:]
|
||||
for state in states[entity_id]:
|
||||
if state.last_changed == one:
|
||||
# If the state is recorded before the start time
|
||||
# start it will have its last_updated and last_changed
|
||||
# set to the start time.
|
||||
if state.last_updated < one_and_half:
|
||||
state.last_updated = one_and_half
|
||||
state.last_changed = one_and_half
|
||||
|
||||
hist = get_significant_states(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue