From 2b2fac7c13808b5ee9e770eff0cd5183a19d3f30 Mon Sep 17 00:00:00 2001 From: Khalid MOUTAOUAKIL Date: Mon, 6 Apr 2026 17:48:11 +0200 Subject: [PATCH] Dernier patch: date/semaine depuis Excel, colonne triable, couleur vert/jaune/rouge Co-Authored-By: Claude Opus 4.6 (1M context) --- app/routers/audit_full.py | 8 ++++++++ app/services/server_audit_full_service.py | 1 + app/templates/audit_full_list.html | 2 ++ 3 files changed, 11 insertions(+) diff --git a/app/routers/audit_full.py b/app/routers/audit_full.py index 58cc347..d3e8eed 100644 --- a/app/routers/audit_full.py +++ b/app/routers/audit_full.py @@ -175,6 +175,14 @@ async def audit_full_list(request: Request, db=Depends(get_db)): audits.sort(key=uptime_days, reverse=(sort_dir == "desc")) elif sort == "reboot": audits.sort(key=lambda a: (1 if a.reboot_required else 0), reverse=(sort_dir == "desc")) + elif sort == "patch": + def patch_sort_key(a): + if a.last_patch_date: + return a.last_patch_date + elif a.last_patch_year and a.last_patch_week: + return f"{a.last_patch_year}-{a.last_patch_week}" + return "" + audits.sort(key=patch_sort_key, reverse=(sort_dir == "desc")) # Pagination total_filtered = len(audits) diff --git a/app/services/server_audit_full_service.py b/app/services/server_audit_full_service.py index f0ba6fc..3d88dc5 100644 --- a/app/services/server_audit_full_service.py +++ b/app/services/server_audit_full_service.py @@ -403,6 +403,7 @@ def get_latest_audits(db, limit=100): return db.execute(text(""" SELECT DISTINCT ON (hostname) id, server_id, hostname, audit_date, os_release, kernel, uptime, status, reboot_required, + last_patch_date, last_patch_week, last_patch_year, jsonb_array_length(COALESCE(services, '[]')) as svc_count, jsonb_array_length(COALESCE(listen_ports, '[]')) as port_count, jsonb_array_length(COALESCE(connections, '[]')) as conn_count, diff --git a/app/templates/audit_full_list.html b/app/templates/audit_full_list.html index 2b6d5cf..3b8a5a3 100644 --- a/app/templates/audit_full_list.html +++ b/app/templates/audit_full_list.html @@ -103,6 +103,7 @@ Ports Conn Reboot {% if sort == 'reboot' %}{{ '▲' if sort_dir == 'asc' else '▼' }}{% endif %} + Dernier patch {% if sort == 'patch' %}{{ '▲' if sort_dir == 'asc' else '▼' }}{% endif %} Date @@ -117,6 +118,7 @@ {{ a.port_count }} {{ a.conn_count }} {% if a.reboot_required %}Oui{% else %}Non{% endif %} + {% if a.last_patch_date %}{{ a.last_patch_date }}{% elif a.last_patch_week %}{{ a.last_patch_week }} {{ a.last_patch_year }}{% else %}-{% endif %} {{ a.audit_date.strftime('%d/%m %H:%M') if a.audit_date else '-' }} {% endfor %}