Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logic for purge of recorder runs #130378

Merged
merged 3 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/recorder/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ def delete_recorder_runs_rows(
"""Delete recorder_runs rows."""
return lambda_stmt(
lambda: delete(RecorderRuns)
.filter(RecorderRuns.start < purge_before)
.filter(RecorderRuns.end < purge_before)
.filter(RecorderRuns.run_id != current_run_id)
.execution_options(synchronize_session=False)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/components/recorder/test_purge.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ async def test_purge_old_recorder_runs(

with session_scope(hass=hass) as session:
recorder_runs = session.query(RecorderRuns)
assert recorder_runs.count() == 1
assert recorder_runs.count() == 3


async def test_purge_old_statistics_runs(
Expand Down
2 changes: 1 addition & 1 deletion tests/components/recorder/test_purge_v32_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ async def test_purge_old_recorder_runs(

with session_scope(hass=hass) as session:
recorder_runs = session.query(RecorderRuns)
assert recorder_runs.count() == 1
assert recorder_runs.count() == 3


async def test_purge_old_statistics_runs(
Expand Down