Fix histogramme: cancelled_weeks séparés, barres empilées vert+rouge par semaine
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4517dcdd39
commit
8286fe0624
@ -287,16 +287,19 @@ async def audit_full_patching(request: Request, db=Depends(get_db)):
|
|||||||
|
|
||||||
patch_weekly = []
|
patch_weekly = []
|
||||||
if year == 2026:
|
if year == 2026:
|
||||||
patch_weekly = db.execute(text(
|
patch_weekly = db.execute(text("""
|
||||||
"SELECT pw.week, SUM(pw.patched) as patched, SUM(pw.cancelled) as cancelled FROM ("
|
SELECT week, SUM(patched)::int as patched, SUM(cancelled)::int as cancelled FROM (
|
||||||
" SELECT unnest(string_to_array(patch_weeks_2026, ',')) as week,"
|
SELECT unnest(string_to_array(patch_weeks_2026, ',')) as week, 1 as patched, 0 as cancelled
|
||||||
" CASE WHEN patch_status_2026 = 'patched' THEN 1 ELSE 0 END as patched,"
|
FROM server_audit_full
|
||||||
" CASE WHEN patch_status_2026 IN ('cancelled','reported') THEN 1 ELSE 0 END as cancelled"
|
WHERE status IN ('ok','partial') AND patch_weeks_2026 IS NOT NULL AND patch_weeks_2026 != ''
|
||||||
" FROM server_audit_full"
|
AND id IN (SELECT DISTINCT ON (hostname) id FROM server_audit_full WHERE status IN ('ok','partial') ORDER BY hostname, audit_date DESC)
|
||||||
" WHERE status IN ('ok','partial') AND patch_weeks_2026 IS NOT NULL AND patch_weeks_2026 != ''"
|
UNION ALL
|
||||||
" AND id IN (SELECT DISTINCT ON (hostname) id FROM server_audit_full WHERE status IN ('ok','partial') ORDER BY hostname, audit_date DESC)"
|
SELECT unnest(string_to_array(cancelled_weeks_2026, ',')) as week, 0 as patched, 1 as cancelled
|
||||||
") pw WHERE pw.week != '' GROUP BY pw.week ORDER BY pw.week"
|
FROM server_audit_full
|
||||||
)).fetchall()
|
WHERE status IN ('ok','partial') AND cancelled_weeks_2026 IS NOT NULL AND cancelled_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)
|
||||||
|
) combined WHERE week != '' GROUP BY week ORDER BY week
|
||||||
|
""")).fetchall()
|
||||||
|
|
||||||
all_domains = db.execute(text("SELECT code, name, 'domain' as type FROM domains ORDER BY name")).fetchall()
|
all_domains = db.execute(text("SELECT code, name, 'domain' as type FROM domains ORDER BY name")).fetchall()
|
||||||
all_zones = db.execute(text("SELECT name as code, name, 'zone' as type FROM zones ORDER BY name")).fetchall()
|
all_zones = db.execute(text("SELECT name as code, name, 'zone' as type FROM zones ORDER BY name")).fetchall()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user