Comparaison 2026 vs 2025: barres progression, écart serveurs et points
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8286fe0624
commit
340970c108
@ -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,
|
||||
|
||||
@ -55,6 +55,46 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Comparaison Y-1 -->
|
||||
{% 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 %}
|
||||
<div class="card p-3 mb-4">
|
||||
<div class="text-xs text-gray-500 mb-2">Comparaison 2026 (S14) vs 2025 (année complète)</div>
|
||||
<div style="display:flex;gap:12px;align-items:center;">
|
||||
<div style="flex:1;">
|
||||
<div class="flex justify-between text-xs mb-1">
|
||||
<span class="text-cyber-accent font-bold">2026 (en cours)</span>
|
||||
<span class="font-bold {% if pct_current >= 80 %}text-cyber-green{% elif pct_current >= 50 %}text-cyber-yellow{% else %}text-cyber-red{% endif %}">{{ compare.current_patched }} / {{ compare.total }} ({{ pct_current }}%)</span>
|
||||
</div>
|
||||
<div style="height:10px;background:#1f2937;border-radius:4px;overflow:hidden;">
|
||||
<div style="height:100%;width:{{ pct_current }}%;background:#22c55e;border-radius:4px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="flex:1;">
|
||||
<div class="flex justify-between text-xs mb-1">
|
||||
<span class="text-gray-400">2025 (total)</span>
|
||||
<span class="text-gray-400">{{ compare.prev_year_total }} / {{ compare.total }} ({{ pct_prev }}%)</span>
|
||||
</div>
|
||||
<div style="height:10px;background:#1f2937;border-radius:4px;overflow:hidden;">
|
||||
<div style="height:100%;width:{{ pct_prev }}%;background:#6b7280;border-radius:4px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="min-width:120px;text-align:center;">
|
||||
<div class="text-lg font-bold {% if diff >= 0 %}text-cyber-green{% else %}text-cyber-red{% endif %}">
|
||||
{% if diff >= 0 %}+{% endif %}{{ diff }}
|
||||
</div>
|
||||
<div style="font-size:10px;" class="{% if diff_pct >= 0 %}text-cyber-green{% else %}text-cyber-red{% endif %}">
|
||||
{% if diff_pct >= 0 %}+{% endif %}{{ diff_pct }} pts vs 2025
|
||||
</div>
|
||||
<div style="font-size:9px;" class="text-gray-600">S14 vs année complète</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<!-- Graphe + domaines -->
|
||||
<div class="grid grid-cols-2 gap-4 mb-4">
|
||||
{% if patch_weekly %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user