Skip to content

Commit 80d3a51

Browse files
author
Tom Lasswell
committed
feat(readme): add last-updated UTC timestamp to status graphs
1 parent 2c13cf1 commit 80d3a51

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

scripts/status_badges.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ def _now() -> datetime:
5656
return datetime.now(timezone.utc)
5757

5858

59+
def stamp() -> str:
60+
"""UTC last-updated timestamp shown in graph footers."""
61+
return f"updated {_now():%Y-%m-%d %H:%M} UTC"
62+
63+
5964
def human(n: int) -> str:
6065
if n >= 10000:
6166
return f"{n / 1000:.0f}k"
@@ -205,9 +210,8 @@ def render_installs_svg(history: list, fork_total: int, official_total: int) ->
205210
else:
206211
s.append(txt(gx0 + gw / 2, gy0 + gh / 2, "collecting history…", 12, MUTED, anchor="middle"))
207212

208-
foot = f"Home Assistant analytics · {_now():%b %-d}"
209-
s.append(txt(pad, h - 14, foot, 10.5, MUTED))
210-
s.append(txt(w - pad, h - 14, f"of {human(official_total)} domain total", 10.5, MUTED, anchor="end"))
213+
s.append(txt(pad, h - 14, f"HA analytics · of {human(official_total)} domain total", 10.5, MUTED))
214+
s.append(txt(w - pad, h - 14, stamp(), 10.5, MUTED, anchor="end"))
211215
s.append("</svg>")
212216
return "\n".join(s)
213217

@@ -258,8 +262,9 @@ def render_versions_svg(fork_counts: dict[str, int], fork_total: int) -> str:
258262
pct = c / fork_total * 100 if fork_total else 0
259263
s.append(txt(w - pad, cy, f"{human(c)} · {pct:.0f}%", 10.5, MUTED, anchor="end"))
260264

261-
foot = f"newest {latest} · {len(fork_counts)} releases in use · {_now():%b %-d}" if fork_total else "collecting…"
265+
foot = f"newest {latest} · {len(fork_counts)} releases in use" if fork_total else "collecting…"
262266
s.append(txt(pad, h - 11, foot, 10.5, MUTED))
267+
s.append(txt(w - pad, h - 11, stamp(), 10.5, MUTED, anchor="end"))
263268
s.append("</svg>")
264269
return "\n".join(s)
265270

@@ -374,8 +379,8 @@ def render_uptime_svg(history: list) -> str:
374379
if not days:
375380
s.append(txt(w / 2, by0 + bh / 2 + 4, "collecting history…", 12, MUTED, anchor="middle"))
376381

377-
foot = f"openapi + app2 · hourly · {_now():%b %-d}"
378-
s.append(txt(pad, h - 12, foot, 10.5, MUTED))
382+
s.append(txt(pad, h - 12, "openapi + app2 · hourly", 10.5, MUTED))
383+
s.append(txt(w - pad, h - 12, stamp(), 10.5, MUTED, anchor="end"))
379384
s.append("</svg>")
380385
return "\n".join(s)
381386

0 commit comments

Comments
 (0)