From 340970c108db064b8cc706802c828ff059caae3c Mon Sep 17 00:00:00 2001 From: Khalid MOUTAOUAKIL Date: Mon, 6 Apr 2026 23:45:17 +0200 Subject: [PATCH] =?UTF-8?q?Comparaison=202026=20vs=202025:=20barres=20prog?= =?UTF-8?q?ression,=20=C3=A9cart=20serveurs=20et=20points?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- app/routers/audit_full.py | 22 ++++++++++++++ app/templates/audit_full_patching.html | 40 ++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) 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 %} +
+
Comparaison 2026 (S14) vs 2025 (année complète)
+
+
+
+ 2026 (en cours) + {{ compare.current_patched }} / {{ compare.total }} ({{ pct_current }}%) +
+
+
+
+
+
+
+ 2025 (total) + {{ compare.prev_year_total }} / {{ compare.total }} ({{ pct_prev }}%) +
+
+
+
+
+
+
+ {% if diff >= 0 %}+{% endif %}{{ diff }} +
+
+ {% if diff_pct >= 0 %}+{% endif %}{{ diff_pct }} pts vs 2025 +
+
S14 vs année complète
+
+
+
+{% endif %} +
{% if patch_weekly %}