mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Fix purge of legacy database events that are not state changed (#72815)
This commit is contained in:
parent
1139136365
commit
2f3359f376
@ -631,7 +631,7 @@ def find_legacy_event_state_and_attributes_and_data_ids_to_purge(
|
|||||||
lambda: select(
|
lambda: select(
|
||||||
Events.event_id, Events.data_id, States.state_id, States.attributes_id
|
Events.event_id, Events.data_id, States.state_id, States.attributes_id
|
||||||
)
|
)
|
||||||
.join(States, Events.event_id == States.event_id)
|
.outerjoin(States, Events.event_id == States.event_id)
|
||||||
.filter(Events.time_fired < purge_before)
|
.filter(Events.time_fired < purge_before)
|
||||||
.limit(MAX_ROWS_TO_PURGE)
|
.limit(MAX_ROWS_TO_PURGE)
|
||||||
)
|
)
|
||||||
|
@ -26,7 +26,7 @@ from homeassistant.components.recorder.services import (
|
|||||||
)
|
)
|
||||||
from homeassistant.components.recorder.tasks import PurgeTask
|
from homeassistant.components.recorder.tasks import PurgeTask
|
||||||
from homeassistant.components.recorder.util import session_scope
|
from homeassistant.components.recorder.util import session_scope
|
||||||
from homeassistant.const import EVENT_STATE_CHANGED, STATE_ON
|
from homeassistant.const import EVENT_STATE_CHANGED, EVENT_THEMES_UPDATED, STATE_ON
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
from homeassistant.helpers.typing import ConfigType
|
from homeassistant.helpers.typing import ConfigType
|
||||||
from homeassistant.util import dt as dt_util
|
from homeassistant.util import dt as dt_util
|
||||||
@ -925,6 +925,15 @@ async def test_purge_without_state_attributes_filtered_states_to_empty(
|
|||||||
time_fired=timestamp,
|
time_fired=timestamp,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
session.add(
|
||||||
|
Events(
|
||||||
|
event_id=event_id + 1,
|
||||||
|
event_type=EVENT_THEMES_UPDATED,
|
||||||
|
event_data="{}",
|
||||||
|
origin="LOCAL",
|
||||||
|
time_fired=timestamp,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
service_data = {"keep_days": 10}
|
service_data = {"keep_days": 10}
|
||||||
_add_db_entries(hass)
|
_add_db_entries(hass)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user