fix: streamline cleanup_old_data calls by consolidating argument formatting

This commit is contained in:
Rightup
2026-07-20 20:59:47 +01:00
parent 6bd2ec4586
commit dc33c82f66
3 changed files with 5 additions and 15 deletions
+2 -6
View File
@@ -1706,13 +1706,9 @@ class RepeaterHandler(BaseHandler):
if current_time - self.last_db_cleanup >= 21600:
if self.storage:
try:
retention_cfg = self.config.get("storage", {}).get(
"retention", {}
)
retention_cfg = self.config.get("storage", {}).get("retention", {})
retention_days = retention_cfg.get("sqlite_cleanup_days", 31)
companion_events_days = retention_cfg.get(
"companion_events_days", 31
)
companion_events_days = retention_cfg.get("companion_events_days", 31)
self.storage.cleanup_old_data(
days=retention_days,
companion_events_days=companion_events_days,
+1 -3
View File
@@ -2774,9 +2774,7 @@ class TestEngineTransmissionAndBackgroundLifecycle:
handler._record_crc_errors_async.assert_awaited_once()
handler._send_periodic_advert_async.assert_awaited_once()
handler.cleanup_cache.assert_called_once()
handler.storage.cleanup_old_data.assert_called_once_with(
days=31, companion_events_days=31
)
handler.storage.cleanup_old_data.assert_called_once_with(days=31, companion_events_days=31)
@pytest.mark.asyncio
async def test_background_timer_loop_continues_when_db_cleanup_fails(self, handler):
+2 -6
View File
@@ -20,9 +20,7 @@ def _bare_collector() -> StorageCollector:
def test_cleanup_passes_companion_events_days_through():
collector = _bare_collector()
collector.cleanup_old_data(days=10, companion_events_days=20)
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(
10, companion_events_days=20
)
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(10, companion_events_days=20)
def test_cleanup_defaults_match_engine_callsite():
@@ -30,6 +28,4 @@ def test_cleanup_defaults_match_engine_callsite():
# for any older callers that only know about ``days``.
collector = _bare_collector()
collector.cleanup_old_data(days=7)
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(
7, companion_events_days=None
)
collector.sqlite_handler.cleanup_old_data.assert_called_once_with(7, companion_events_days=None)