From 6dff1ed13725b058c893d11aad3663206bfd10bc Mon Sep 17 00:00:00 2001 From: Tim Eertmoed Date: Thu, 3 Sep 2026 12:48:32 +0200 Subject: [PATCH] Banner: Einzahl, wo eines gemeint ist "1 Clients online" liest man jeden Tag einmal zu oft. Co-Authored-By: Claude Opus 5 --- deploy/tesm-motd | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/deploy/tesm-motd b/deploy/tesm-motd index 1092bbf..668c8ab 100644 --- a/deploy/tesm-motd +++ b/deploy/tesm-motd @@ -63,6 +63,11 @@ DASHBOARD_COUNT_SQL = """ """ +def _zahl(anzahl: int, singular: str, plural: str) -> str: + """Zahl mit passendem Wort. "1 Clients" liest man jeden Tag einmal zu oft.""" + return f"{BOLD}{anzahl}{RESET} {singular if anzahl == 1 else plural}" + + def _oeffnen(root: Path) -> sqlite3.Connection: pfad = root / "data" / "app.db" conn = sqlite3.connect(f"file:{pfad.as_posix()}?mode=ro", uri=True, timeout=1.0) @@ -74,12 +79,15 @@ def _flotte(conn: sqlite3.Connection) -> str: row = conn.execute(DASHBOARD_COUNT_SQL).fetchone() online = int(row["online"] or 0) offline = int(row["offline"] or 0) - teile = [f"{BOLD}{online}{RESET} Clients online", f"{BOLD}{offline}{RESET} nicht erreichbar"] + teile = [ + _zahl(online, "Client online", "Clients online"), + f"{BOLD}{offline}{RESET} nicht erreichbar", + ] # Nur nennen, wenn es sie gibt: eine Null bei "startet neu" ist keine # Auskunft, sondern Fuellmaterial. restarting = int(row["restarting"] or 0) if restarting: - teile.append(f"{BOLD}{restarting}{RESET} startet neu") + teile.append(_zahl(restarting, "startet neu", "starten neu")) unbekannt = int(row["unknown"] or 0) if unbekannt: teile.append(f"{DIM}{unbekannt} ohne Pruefung{RESET}") @@ -116,7 +124,7 @@ def _dhcp() -> str: except ValueError: continue aktiv = sum(1 for ablauf, zustand in letzte.values() if zustand == "0" and ablauf > jetzt) - return f"{aktiv} Leases aktiv" + return f"{aktiv} {'Lease' if aktiv == 1 else 'Leases'} aktiv" def _lizenzen(conn: sqlite3.Connection) -> str: @@ -127,7 +135,11 @@ def _lizenzen(conn: sqlite3.Connection) -> str: ).fetchone()[0] or 0 ) - return f"{BOLD}{kunden}{RESET} Kunden · {BOLD}{lizenzen}{RESET} Lizenzen ausgestellt" + return ( + _zahl(kunden, "Kunde", "Kunden") + + " · " + + _zahl(lizenzen, "Lizenz ausgestellt", "Lizenzen ausgestellt") + ) def main(argv: list[str] | None = None) -> int: