Implement logging for Ban System API checks and add endpoint for raw stats retrieval

- Added logging for Ban System API status checks, including whether the system is enabled and its configured URL.
- Introduced a new endpoint `/stats/raw` to fetch raw statistics from the Ban System API for debugging purposes.
- Enhanced logging to capture raw stats response for better monitoring.
This commit is contained in:
PEDZEO
2026-01-16 18:51:19 +03:00
parent 29d0190a05
commit 7ef416eff2

View File

@@ -39,6 +39,9 @@ router = APIRouter(prefix="/admin/ban-system", tags=["Cabinet Admin Ban System"]
def _get_ban_api() -> BanSystemAPI:
"""Get Ban System API instance."""
logger.info(f"Ban System check - enabled: {settings.is_ban_system_enabled()}, configured: {settings.is_ban_system_configured()}")
logger.info(f"Ban System URL: {settings.get_ban_system_api_url()}")
if not settings.is_ban_system_enabled():
raise HTTPException(
status_code=status.HTTP_503_SERVICE_UNAVAILABLE,
@@ -93,6 +96,16 @@ async def get_ban_system_status(
# === Stats ===
@router.get("/stats/raw")
async def get_stats_raw(
admin: User = Depends(get_current_admin_user),
) -> dict:
"""Get raw stats from Ban System API for debugging."""
api = _get_ban_api()
data = await _api_request(api, "get_stats")
return {"raw_response": data}
@router.get("/stats", response_model=BanSystemStatsResponse)
async def get_stats(
admin: User = Depends(get_current_admin_user),
@@ -101,6 +114,8 @@ async def get_stats(
api = _get_ban_api()
data = await _api_request(api, "get_stats")
logger.info(f"Ban System raw stats: {data}")
# Extract punishment stats
punishment_stats = data.get("punishment_stats") or {}