Files
checkbot/app/web/retention_section.py
patrickandClaude Sonnet 5.5 9c4f7366eb
test / pytest (3.11) (push) Canceled after 0s
test / pytest (3.13) (push) Canceled after 0s
feat: Phase 6 prompt versioning with test area, retention
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 02:17:01 +01:00

43 lines
1.1 KiB
Python

from ..retention import COUNT_KEYS, SETTINGS, validate_values
from .sections import Field, Section
SLUG = "retention"
RUN_PATH = "/retention/run"
COUNT_LABELS = {
"alerts": "Alarme",
"deliveries": "Zustellungen",
"agent_runs": "Agenten-Läufe",
"state_log": "Statusverlauf",
"audit": "Audit-Einträge",
"mutes": "Stummschaltungen",
}
def format_counts(counts: dict[str, int]) -> str:
return ", ".join(f"{COUNT_LABELS[key]}: {counts.get(key, 0)}" for key in COUNT_KEYS)
def context(state) -> dict:
last = state.runtime.retention.last_run()
return {
"retention_last": last,
"retention_counts": format_counts(last.counts) if last else "",
"retention_settings": SETTINGS,
"retention_run_path": RUN_PATH,
}
SECTION = Section(
slug=SLUG,
title="Aufbewahrung",
fields=tuple(
Field(s.key, f"{s.label} in Tagen ({s.minimum} bis {s.maximum})", default=str(s.default),
placeholder=f"{s.minimum} bis {s.maximum}")
for s in SETTINGS
),
validate=validate_values,
optional=True,
extra_template="_retention_extra.html",
extra_context=context,
)