Complete Task 11 by moving history_archive_repo import to history_sync top-level

This commit is contained in:
2026-04-14 09:28:22 +02:00
parent 21eabb1f0f
commit 88715ab07f
2 changed files with 9 additions and 9 deletions

View File

@@ -9,20 +9,20 @@ from __future__ import annotations
import datetime
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import aiosqlite
from app.config import Settings
import structlog
from app.db import open_db
from app.repositories import fail2ban_db_repo
from app.repositories.history_archive_repo import archive_ban_event
from app.utils.fail2ban_db_utils import get_fail2ban_db_path
from app.utils.runtime_state import get_effective_settings
if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
import aiosqlite
from fastapi import FastAPI
from app.config import Settings
log: structlog.stdlib.BoundLogger = structlog.get_logger()
#: Stable APScheduler job id.
@@ -35,7 +35,7 @@ HISTORY_SYNC_INTERVAL: int = 300
BACKFILL_WINDOW: int = 648000
async def _get_db(settings: "Settings") -> tuple[aiosqlite.Connection, bool]:
async def _get_db(settings: Settings) -> tuple[aiosqlite.Connection, bool]:
db = await open_db(settings.database_path)
return db, True
@@ -48,7 +48,7 @@ async def _get_last_archive_ts(db) -> int | None:
return int(row[0])
async def _run_sync_with_settings(settings: "Settings") -> None:
async def _run_sync_with_settings(settings: Settings) -> None:
socket_path: str = settings.fail2ban_socket
db, close_db = await _get_db(settings)
@@ -76,8 +76,6 @@ async def _run_sync_with_settings(settings: "Settings") -> None:
if not rows:
break
from app.repositories.history_archive_repo import archive_ban_event
for row in rows:
await archive_ban_event(
db=db,