diff --git a/app/routers/audit_full.py b/app/routers/audit_full.py index b7c6e84..1932369 100644 --- a/app/routers/audit_full.py +++ b/app/routers/audit_full.py @@ -272,6 +272,27 @@ async def audit_full_patching(request: Request, db=Depends(get_db)): f" AND saf.{_latest}" )).fetchone() + # Comparaison Y-1 + compare = None + from datetime import datetime as _dt + current_week = _dt.now().isocalendar()[1] + if year == 2026: + compare = db.execute(text( + f"SELECT" + f" COUNT(*) FILTER (WHERE patch_count_2026 >= 1) as current_patched," + f" COUNT(*) FILTER (WHERE patch_count_2025 >= 1) as prev_year_total," + f" COUNT(*) as total" + f" FROM server_audit_full WHERE status IN ('ok','partial') AND {_latest}" + )).fetchone() + elif year == 2025: + compare = db.execute(text( + f"SELECT" + f" COUNT(*) FILTER (WHERE patch_count_2025 >= 1) as current_patched," + f" 0 as prev_year_total," + f" COUNT(*) as total" + f" FROM server_audit_full WHERE status IN ('ok','partial') AND {_latest}" + )).fetchone() + patch_by_domain = db.execute(text( f"SELECT d.name as domain, d.code," f" COUNT(DISTINCT saf.hostname) as total," @@ -362,6 +383,7 @@ async def audit_full_patching(request: Request, db=Depends(get_db)): ctx.update({ "app_name": APP_NAME, "year": year, "kpis": kpis, "kpis_secops": kpis_secops, "kpis_other": kpis_other, + "compare": compare, "patch_by_domain": patch_by_domain, "patch_weekly": patch_weekly, "servers": servers_page, "all_domains": all_domains, "all_zones": all_zones, "search": search, "domain": domain, "scope": scope, diff --git a/app/templates/audit_full_patching.html b/app/templates/audit_full_patching.html index 4715b62..30e5ce5 100644 --- a/app/templates/audit_full_patching.html +++ b/app/templates/audit_full_patching.html @@ -55,6 +55,46 @@ + +{% if compare and year == 2026 %} +{% set pct_current = (compare.current_patched / compare.total * 100)|int if compare.total > 0 else 0 %} +{% set pct_prev = (compare.prev_year_total / compare.total * 100)|int if compare.total > 0 else 0 %} +{% set diff = compare.current_patched - compare.prev_year_total %} +{% set diff_pct = pct_current - pct_prev %} +