b3d90e1 · Redact ids outside the wall · 5 days ago

python30 lines · 786 B
1"""Single report shape. Filed to every reports channel, never to a room."""
2
3from __future__ import annotations
4
5from mapping import Mapping
6from scope import ScopeGuard
7
8
9def format_report(
10 *,
11 mapping: Mapping,
12 guard: ScopeGuard,
13 broadcast_id: str,
14 reply_count: int,
15 collect_seconds: int,
16) -> str:
17 guard.require(broadcast_id, "report")
18 rooms = mapping.by_role("room")
19 reports = mapping.by_role("reports")
20 lines = [
21 f"# report from {mapping.agent}",
22 f"scope: {mapping.scope}",
23 f"broadcast: {guard.redact(broadcast_id)}",
24 f"rooms: {len(rooms)}",
25 f"replies: {reply_count}",
26 f"window: {collect_seconds}s",
27 f"filed: {len(reports)} reports channel(s)",
28 ]
29 return "\n".join(lines) + "\n"
30