feat(dashboard): admin storage stats page #78

Merged
rcsheets merged 1 commit from feat/admin-storage-stats into main 2026-07-23 11:45:48 +00:00
Owner

Adds an admin-only Storage page at /admin/storage showing overall database size plus per-table row counts and on-disk sizes (data incl. TOAST, indexes, total, avg bytes/row).

  • Tables enumerated from pg_stat_user_tables, so new tables appear automatically
  • Exact COUNT(*) per table (estimates lag until autovacuum; all tables here are small)
  • Degraded (no-DB) mode shows a notice instead of the table
  • Render tests for populated/degraded states + humanBytes unit cases

🤖 Generated with Claude Code

Adds an admin-only **Storage** page at `/admin/storage` showing overall database size plus per-table row counts and on-disk sizes (data incl. TOAST, indexes, total, avg bytes/row). - Tables enumerated from `pg_stat_user_tables`, so new tables appear automatically - Exact `COUNT(*)` per table (estimates lag until autovacuum; all tables here are small) - Degraded (no-DB) mode shows a notice instead of the table - Render tests for populated/degraded states + `humanBytes` unit cases 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(dashboard): admin storage stats page
All checks were successful
ci / check (pull_request) Successful in 45s
2a0e839788
Add /admin/storage showing overall database size plus per-table row
counts and on-disk sizes (data incl. TOAST, indexes, total, avg/row).
Tables are enumerated from pg_stat_user_tables so future tables appear
automatically; row counts are exact COUNT(*) rather than n_live_tup
estimates since every table here is small.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Collaborator

Automated review by pr-reviewer v0.37.0 | Safety Check | Claude Sonnet 5 | tracking id r-61e792-0be69f
This is an AI-generated review and may contain mistakes.

Status: Completed


⚠️ The primary review (Mistral Small) failed. The review below is from Claude Sonnet 5, which reviewed the same diff.

Verdict: LGTM — Straightforward admin storage stats page addition with safe identifier handling and no exposed secrets or breaking changes.

Reviewed the diff:

  • handleStorage is properly gated by admin route grouping and handles nil stats (degraded mode) safely.
  • StorageStats query: table/schema names come from pg_stat_user_tables (catalog), not user input, and are further passed through pgx.Identifier{}.Sanitize() before being interpolated into SELECT COUNT(*) FROM <ident> — this avoids SQL injection since identifiers aren't user-controlled and are sanitized regardless.
  • humanBytes/divInt64 template funcs are simple and guarded against divide-by-zero, with template using {{if .Rows}} guard too.
  • No secrets, no large binaries, no debug code committed.
  • Per-table COUNT(*) loop could be slow on much larger tables, but PR explicitly notes all tables are small; not a correctness issue.
  • Test coverage included for render paths and humanBytes.

Nothing here looks like an accidental commit, security issue, or breaking change.

*Automated review by [pr-reviewer](https://git.brooktrails.org/brooktrails/pr-reviewer) v0.37.0 | Safety Check | Claude Sonnet 5 | tracking id `r-61e792-0be69f`* *This is an AI-generated review and may contain mistakes.* **Status:** ✅ Completed --- > ⚠️ The primary review (**Mistral Small**) failed. The review below is from **Claude Sonnet 5**, which reviewed the same diff. **✅ Verdict: LGTM** — Straightforward admin storage stats page addition with safe identifier handling and no exposed secrets or breaking changes. Reviewed the diff: - `handleStorage` is properly gated by admin route grouping and handles nil stats (degraded mode) safely. - `StorageStats` query: table/schema names come from `pg_stat_user_tables` (catalog), not user input, and are further passed through `pgx.Identifier{}.Sanitize()` before being interpolated into `SELECT COUNT(*) FROM <ident>` — this avoids SQL injection since identifiers aren't user-controlled and are sanitized regardless. - `humanBytes`/`divInt64` template funcs are simple and guarded against divide-by-zero, with template using `{{if .Rows}}` guard too. - No secrets, no large binaries, no debug code committed. - Per-table `COUNT(*)` loop could be slow on much larger tables, but PR explicitly notes all tables are small; not a correctness issue. - Test coverage included for render paths and humanBytes. Nothing here looks like an accidental commit, security issue, or breaking change.
rcsheets deleted branch feat/admin-storage-stats 2026-07-23 11:45:49 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
brooktrails/pr-reviewer!78
No description provided.