refactor(backend): clean up jail service, add error handling service
- Extract jail status/processing to helper functions - Add error_handling.py service for centralized error handling - Update config.py with validation and defaults - Update .env.example with all config options - Remove obsolete Tasks.md, add Service-Development.md - Minor fixes across routers and services Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -33,7 +33,7 @@ from app.models.history_domain import (
|
||||
)
|
||||
from app.repositories import fail2ban_db_repo
|
||||
from app.repositories import history_archive_repo as default_history_archive_repo
|
||||
from app.utils.constants import DEFAULT_PAGE_SIZE, MAX_PAGE_SIZE
|
||||
from app.utils.constants import DEFAULT_PAGE_SIZE
|
||||
from app.utils.fail2ban_db_utils import parse_data_json, ts_to_iso
|
||||
from app.utils.time_utils import since_unix
|
||||
|
||||
@@ -184,6 +184,7 @@ async def list_history(
|
||||
source: str = "fail2ban",
|
||||
page: int = 1,
|
||||
page_size: int = DEFAULT_PAGE_SIZE,
|
||||
max_page_size: int = 500,
|
||||
http_session: aiohttp.ClientSession | None = None,
|
||||
geo_enricher: GeoEnricher | None = None,
|
||||
db: aiosqlite.Connection | None = None,
|
||||
@@ -203,7 +204,8 @@ async def list_history(
|
||||
ip_filter: If given, restrict results to bans for this exact IP
|
||||
(or a prefix — the query uses ``LIKE ip_filter%``).
|
||||
page: 1-based page number (default: ``1``).
|
||||
page_size: Maximum items per page, capped at ``MAX_PAGE_SIZE``.
|
||||
page_size: Maximum items per page, capped at ``max_page_size``.
|
||||
max_page_size: Deployment-configured maximum page size (default: ``500``).
|
||||
http_session: Optional shared :class:`aiohttp.ClientSession` (unused;
|
||||
kept for backward compatibility).
|
||||
geo_enricher: Optional async callable ``(ip: str) -> GeoInfo | None``.
|
||||
@@ -216,7 +218,7 @@ async def list_history(
|
||||
:class:`~app.models.history_domain.DomainHistoryList` with paginated items
|
||||
and the total matching count.
|
||||
"""
|
||||
effective_page_size: int = min(page_size, MAX_PAGE_SIZE)
|
||||
effective_page_size: int = min(page_size, max_page_size)
|
||||
|
||||
# Build WHERE clauses dynamically.
|
||||
since: int | None = None
|
||||
|
||||
Reference in New Issue
Block a user