feat(ui): shared |bytes |rate |duration |ago filters and status_class from Settings → Thresholds (#5093)
#5093 "Shared format filters and status_class driven by Settings → Thresholds". - steward/core/formatting.py: human_bytes (binary units), human_rate, human_duration (two largest units), ago (a <time> titled with the absolute UTC time) and status_class(value, kind, thresholds) -> ok/warn/crit/unknown, which raises on a kind the thresholds don't name. - app.py registers them as the bytes, rate, duration and ago filters and the status_class global; threshold_style is now graded by status_class (and caps its weight at 500). - Replaces the copies: docker's _human_bytes/_human_uptime, core alerts' _duration, the host-agent fmt_bps/fmt_bytes macros, the Traefik and UniFi byte-rate arithmetic, the swarm-failures ago macro and two uptime spans. - Tests: a table per helper, and every template compiled against the app's filters, so an unknown filter fails CI rather than a page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -85,7 +85,7 @@ def test_silence_is_marked_once_and_cleared_by_data(app):
|
||||
assert st.no_data_since == now - timedelta(minutes=18) + timedelta(seconds=300)
|
||||
[(frm, to, note)] = await events("loud")
|
||||
assert (frm, to) == ("inactive", "no_data")
|
||||
assert note == "no sample for 18m (usually every 60s)"
|
||||
assert note == "no sample for 18m (usually every 1m)"
|
||||
assert len(await events("hushed")) == 1
|
||||
assert sent == [(f"loud {tag}", "no_data", note)] # the hushed rule notifies nobody
|
||||
|
||||
|
||||
Reference in New Issue
Block a user