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 %}