feat(db): table-health readout — per-table bloat metrics in admin card
You can't decide what to maintain without seeing what's bloating. Adds a read-only health panel driven by Postgres' own statistics views. - services/db_maintenance.py: get_table_health() queries pg_stat_user_tables + pg_total_relation_size + pg_database_size — per-table size, live/dead tuples, dead-tuple ratio (the bloat signal), and last (auto)vacuum/(auto)analyze. - routes/admin.py: admin-only GET /api/admin/db-maintenance/health. - SettingsView.vue: 'Table health' table in the maintenance card, all tables sorted by dead tuples, rows >=20% dead-ratio flagged; total DB size shown; refreshes after a Run-now so the dead-tuple drop is visible. - Tests: health row/size shaping + null-timestamp passthrough; route + service surface. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -225,6 +225,14 @@ async def get_db_maintenance():
|
||||
})
|
||||
|
||||
|
||||
@admin_bp.route("/db-maintenance/health", methods=["GET"])
|
||||
@admin_required
|
||||
async def get_db_maintenance_health():
|
||||
"""Read-only per-table bloat/health stats from Postgres + total DB size."""
|
||||
from scribe.services.db_maintenance import get_table_health
|
||||
return jsonify(await get_table_health())
|
||||
|
||||
|
||||
@admin_bp.route("/db-maintenance", methods=["PUT"])
|
||||
@admin_required
|
||||
async def update_db_maintenance():
|
||||
|
||||
Reference in New Issue
Block a user