From 4517dcdd394df3105cf3d9cd8b665f085c8b35d3 Mon Sep 17 00:00:00 2001 From: Khalid MOUTAOUAKIL Date: Mon, 6 Apr 2026 23:27:14 +0200 Subject: [PATCH] =?UTF-8?q?Histogramme=20patching:=20barres=20empil=C3=A9e?= =?UTF-8?q?s=20vert=20(patch=C3=A9)=20+=20rouge=20(annul=C3=A9/report?= =?UTF-8?q?=C3=A9),=20total=20affich=C3=A9?= 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 | 13 ++++++++----- app/templates/audit_full_patching.html | 15 ++++++++++----- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/routers/audit_full.py b/app/routers/audit_full.py index 17eed82..a3aef5e 100644 --- a/app/routers/audit_full.py +++ b/app/routers/audit_full.py @@ -288,11 +288,14 @@ async def audit_full_patching(request: Request, db=Depends(get_db)): patch_weekly = [] if year == 2026: patch_weekly = db.execute(text( - "SELECT last_patch_week as week, COUNT(*) as cnt FROM server_audit_full" - " WHERE status IN ('ok','partial') AND last_patch_year = 2026 AND last_patch_week IS NOT NULL" - " AND (patch_status_2026 = 'patched' OR patch_status_2026 IS NULL)" - " AND id IN (SELECT DISTINCT ON (hostname) id FROM server_audit_full WHERE status IN ('ok','partial') ORDER BY hostname, audit_date DESC)" - " GROUP BY last_patch_week ORDER BY last_patch_week" + "SELECT pw.week, SUM(pw.patched) as patched, SUM(pw.cancelled) as cancelled FROM (" + " SELECT unnest(string_to_array(patch_weeks_2026, ',')) as week," + " CASE WHEN patch_status_2026 = 'patched' THEN 1 ELSE 0 END as patched," + " CASE WHEN patch_status_2026 IN ('cancelled','reported') THEN 1 ELSE 0 END as cancelled" + " FROM server_audit_full" + " WHERE status IN ('ok','partial') AND patch_weeks_2026 IS NOT NULL AND patch_weeks_2026 != ''" + " AND id IN (SELECT DISTINCT ON (hostname) id FROM server_audit_full WHERE status IN ('ok','partial') ORDER BY hostname, audit_date DESC)" + ") pw WHERE pw.week != '' GROUP BY pw.week ORDER BY pw.week" )).fetchall() all_domains = db.execute(text("SELECT code, name, 'domain' as type FROM domains ORDER BY name")).fetchall() diff --git a/app/templates/audit_full_patching.html b/app/templates/audit_full_patching.html index 0f453eb..4715b62 100644 --- a/app/templates/audit_full_patching.html +++ b/app/templates/audit_full_patching.html @@ -59,13 +59,18 @@
{% if patch_weekly %}
-
Dernière semaine de patch par serveur
+
Serveurs par semaine vert=patché rouge=annulé/reporté
- {% set max_cnt = patch_weekly|map(attribute='cnt')|max %} + {% set max_cnt = patch_weekly|map(attribute='patched')|map('int')|max %} {% for w in patch_weekly %} -
-
{{ w.cnt }}
-
+ {% set total = (w.patched|int) + (w.cancelled|int) %} + {% set max_total = max_cnt if max_cnt > 0 else 1 %} +
+
{{ total }}
+
+ {% if w.cancelled|int > 0 %}
{% endif %} +
+
{{ w.week }}
{% endfor %}