Resolve Task 10 by moving history_archive_repo imports to ban_service top-level

This commit is contained in:
2026-04-14 09:25:23 +02:00
parent a564830abb
commit 21eabb1f0f
2 changed files with 6 additions and 11 deletions

View File

@@ -292,6 +292,8 @@ Importing a private symbol from a peer service module is a layering violation. I
### Task 10 — Replace ban_service deferred local imports with top-level imports ### Task 10 — Replace ban_service deferred local imports with top-level imports
**Status:** Completed
**Severity:** Medium **Severity:** Medium
**Where:** **Where:**

View File

@@ -36,6 +36,10 @@ from app.models.ban import (
JailBanCount as JailBanCountModel, JailBanCount as JailBanCountModel,
) )
from app.repositories import fail2ban_db_repo from app.repositories import fail2ban_db_repo
from app.repositories.history_archive_repo import (
get_all_archived_history,
get_archived_history,
)
from app.utils.fail2ban_db_utils import get_fail2ban_db_path, parse_data_json, ts_to_iso from app.utils.fail2ban_db_utils import get_fail2ban_db_path, parse_data_json, ts_to_iso
if TYPE_CHECKING: if TYPE_CHECKING:
@@ -169,8 +173,6 @@ async def list_bans(
if app_db is None: if app_db is None:
raise ValueError("app_db must be provided when source is 'archive'") raise ValueError("app_db must be provided when source is 'archive'")
from app.repositories.history_archive_repo import get_archived_history
rows, total = await get_archived_history( rows, total = await get_archived_history(
db=app_db, db=app_db,
since=since, since=since,
@@ -337,11 +339,6 @@ async def bans_by_country(
if app_db is None: if app_db is None:
raise ValueError("app_db must be provided when source is 'archive'") raise ValueError("app_db must be provided when source is 'archive'")
from app.repositories.history_archive_repo import (
get_all_archived_history,
get_archived_history,
)
all_rows = await get_all_archived_history( all_rows = await get_all_archived_history(
db=app_db, db=app_db,
since=since, since=since,
@@ -593,8 +590,6 @@ async def ban_trend(
if app_db is None: if app_db is None:
raise ValueError("app_db must be provided when source is 'archive'") raise ValueError("app_db must be provided when source is 'archive'")
from app.repositories.history_archive_repo import get_all_archived_history
all_rows = await get_all_archived_history( all_rows = await get_all_archived_history(
db=app_db, db=app_db,
since=since, since=since,
@@ -692,8 +687,6 @@ async def bans_by_jail(
if app_db is None: if app_db is None:
raise ValueError("app_db must be provided when source is 'archive'") raise ValueError("app_db must be provided when source is 'archive'")
from app.repositories.history_archive_repo import get_all_archived_history
all_rows = await get_all_archived_history( all_rows = await get_all_archived_history(
db=app_db, db=app_db,
since=since, since=since,