feat(audit): every row keeps its date; dividers for Today, Yesterday, Last 7 days, Older (#5214)

The operator found "Today 08:03" in place of a date odd on the audit log,
and asked for the recency groups as dividers instead. |when now always
writes the date ("Thu 8 Oct 08:03"); mark_day_groups gives each entry its
group in the reader's zone, and a divider row opens each group. A scrolled
page carries the group the last one ended in, so it is not opened twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 08:22:03 -04:00
co-authored by Claude Opus 5.5
parent 31e93e96cf
commit 7a444da871
7 changed files with 100 additions and 26 deletions
+13
View File
@@ -9,6 +9,7 @@ from __future__ import annotations
from sqlalchemy import select
from steward.ansible.inventory_gen import run_title, scope_labels
from steward.core.formatting import day_group
from steward.models.alerts import AlertRule, MaintenanceWindow
from steward.models.ansible import AnsibleRun
from steward.models.ansible_inventory import AnsibleGroup, AnsibleTarget
@@ -207,3 +208,15 @@ def detail_facts(detail: dict, scopes: dict[str, str]) -> list[dict]:
text = _plain(value)
facts.append({"label": label, "text": text, "url": url})
return facts
def mark_day_groups(items: list[dict], tz, group: str = "", now=None) -> str:
"""Give each newest-first entry its recency group (formatting.day_group,
in the reader's zone) and whether it opens one, so the page draws a
divider there. `group` is the one the previous page ended in: a group
split across pages is opened once. Returns the group this page ends in."""
for item in items:
item["group"] = day_group(item["event"].timestamp, tz, now)
item["opens_group"] = item["group"] != group
group = item["group"]
return group