feat(settings): Settings → System shows table sizes and what the last cleanup removed (#5469)
#5469 "Settings → System: table sizes and what the last cleanup removed". - Storage: each table's size on disk (pg_total_relation_size, indexes and TOAST included) and Postgres's row estimate (reltuples), largest first, the 15 largest by name and the rest summed, under the database's total size. Read from the catalog only, never by counting rows. - Last cleanup: when it ran, how long it took, and what each pass removed (each aged table, run log files, the metric and Docker rollups, the log ring), or "Nothing was past its window". run_cleanup now returns that summary and keeps it as the cleanup.last_run setting, as reports.last_sent_at does; cleanup_secs (#5467) is recorded from the same figure. - A hint links to where each retention window is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -627,16 +627,20 @@ async def _reports_page(settings: dict, flash):
|
||||
@require_role(UserRole.admin)
|
||||
async def system():
|
||||
"""Steward's own health (#5467): its process metrics now and over the day,
|
||||
each one an alert rule can watch (source "Steward itself")."""
|
||||
from steward.core.health import process_health
|
||||
each one an alert rule can watch (source "Steward itself"); then its
|
||||
tables' sizes and what the last hourly cleanup removed (#5469)."""
|
||||
from steward.core.health import last_cleanup, process_health, table_sizes
|
||||
from steward.core.status import sparkline_svg
|
||||
async with current_app.db_sessionmaker() as db:
|
||||
health = await process_health(db)
|
||||
# Table sizes and the last cleanup (#5469): Postgres's catalog and
|
||||
# what the cleanup kept, never a scan of the tables themselves.
|
||||
storage, cleanup = await table_sizes(db), await last_cleanup(db)
|
||||
for row in health["rows"]:
|
||||
# From zero to the row's own peak, with a floor (UI & Design ruling 8).
|
||||
row["spark"] = sparkline_svg(row["series"], width=120, height=20,
|
||||
stroke="currentColor", floor=1.0) if len(row["series"]) > 1 else ""
|
||||
return await render_template("settings/system.html", **health)
|
||||
return await render_template("settings/system.html", **health, storage=storage, cleanup=cleanup)
|
||||
|
||||
|
||||
@settings_bp.get("/reports/")
|
||||
|
||||
Reference in New Issue
Block a user