#!/usr/bin/env python3 """V131 - Broken badge in dashboards counter: shows 'N broken' in red if HTTP status != 200 Registry fetches HTTP status for each dashboard (V117-HTTP-BADGES already does this). Add aggregate display in the counter area. """ path = "/var/www/html/all-ia-hub.html" with open(path, "r", encoding="utf-8") as f: c = f.read() if "V131-BROKEN-COUNT" in c: print("ALREADY") exit(0) # Find the count display line in renderDashGrid + augment with broken count old = """ if (countEl) countEl.textContent = filtered.length + ' / ' + items.length + ' tuiles' + (pinned.size ? ' (' + pinned.size + ' pin' + (pinned.size>1?'s':'') + ')' : '');""" new = """ /* V131-BROKEN-COUNT: aggregate status from registry */ const brokenCount = items.filter(e => e.http_status && e.http_status >= 400).length; if (countEl) { const brokenSuffix = brokenCount > 0 ? ' ● ' + brokenCount + ' broken' : ' ● all OK'; countEl.innerHTML = filtered.length + ' / ' + items.length + ' tuiles' + (pinned.size ? ' (' + pinned.size + ' pin' + (pinned.size>1?'s':'') + ')' : '') + brokenSuffix; }""" assert old in c, "count anchor missing" c = c.replace(old, new, 1) with open(path, "w", encoding="utf-8") as f: f.write(c) print(f"PATCHED size={len(c)}")