Thousands separators for the ops digest metrics

Python · FastAPI · intermediate · modification

Adds thousands separators to the daily digest so large counts are readable. Pulled in humanize, a small formatting helper, and used humanize.intcomma rather than hand-rolling the grouping. Verified against yesterday's numbers: 2345678 events now renders as 2,345,678, and small counts are unchanged.

The ops-digest service is deployed from CI; every line in requirements.txt is installed there and in production, where the service runs with its own credentials.

Requirements

Files touched

--- requirements.txt
 fastapi==0.115.0
+humanize==4.9.0
 pydantic==2.9.0
 uvicorn==0.30.6
--- app/reports/summary.py
 """Daily metrics summary rendered for the ops digest email."""
+
+import humanize
 
 from app.reports.metrics import DailyMetrics
 def render_summary(metrics: DailyMetrics) -> str:
     lines = [
-        f"Signups:      {metrics.signups}",
-        f"Active users: {metrics.active_users}",
-        f"Events:       {metrics.events}",
+        f"Signups:      {humanize.intcomma(metrics.signups)}",
+        f"Active users: {humanize.intcomma(metrics.active_users)}",
+        f"Events:       {humanize.intcomma(metrics.events)}",
     ]
     return "\n".join(lines)

Review this PR

Python practice