From fa4e0b9f6248a6e92d5e644209a7e1d3d993ded0 Mon Sep 17 00:00:00 2001
From: HotSwapp <47397945+HotSwapp@users.noreply.github.com>
Date: Wed, 8 Oct 2025 12:59:35 -0500
Subject: [PATCH] Add Database Status section to admin panel
- Added table_counts query in /admin route to get record counts for all tables
* Reference tables (TrnsType, TrnsLkup, Footers, FileStat, Employee, etc.)
* Core data tables (Rolodex, LegacyPhone, LegacyFile, Ledger, etc.)
* Specialized tables (PlanInfo, Qdros, Pensions, etc.)
* Modern models (Client, Phone, Case, Transaction, Payment, Document)
- Created Database Status UI section in admin.html
* Four-column layout showing all table categories
* Color-coded badges (green=has data, gray=empty)
* Check mark icons for populated tables
* Table row highlighting based on data presence
* Legend explaining the visual indicators
- Helps users track import progress at a glance
- Shows which tables have been successfully imported
- Distinguishes between legacy and modern model data
---
app/main.py | 58 +++++++++++++++
app/templates/admin.html | 156 +++++++++++++++++++++++++++++++++++++++
2 files changed, 214 insertions(+)
diff --git a/app/main.py b/app/main.py
index dce845f..ddd8af9 100644
--- a/app/main.py
+++ b/app/main.py
@@ -1846,11 +1846,69 @@ async def admin_panel(request: Request, db: Session = Depends(get_db)):
files_by_type[import_type] = []
files_by_type[import_type].append(file_info)
+ # Get record counts for all legacy and modern tables
+ from .models import (
+ # Legacy tables
+ Rolodex, LegacyPhone, LegacyFile, FilesR, FilesV, FileNots,
+ Ledger, Deposits, LegacyPayment, TrnsType, TrnsLkup,
+ Footers, FileStat, Employee, GroupLkup, FileType,
+ Qdros, PlanInfo, Pensions, PensionMarriage, PensionDeath,
+ PensionSchedule, PensionSeparate, PensionResults,
+ RolexV, FVarLkup, RVarLkup,
+ # Modern tables
+ Client, Phone, Case, Transaction, Payment, Document
+ )
+
+ table_counts = {
+ 'reference': {
+ 'TrnsType': db.query(TrnsType).count(),
+ 'TrnsLkup': db.query(TrnsLkup).count(),
+ 'Footers': db.query(Footers).count(),
+ 'FileStat': db.query(FileStat).count(),
+ 'Employee': db.query(Employee).count(),
+ 'GroupLkup': db.query(GroupLkup).count(),
+ 'FileType': db.query(FileType).count(),
+ 'FVarLkup': db.query(FVarLkup).count(),
+ 'RVarLkup': db.query(RVarLkup).count(),
+ },
+ 'core': {
+ 'Rolodex': db.query(Rolodex).count(),
+ 'LegacyPhone': db.query(LegacyPhone).count(),
+ 'RolexV': db.query(RolexV).count(),
+ 'LegacyFile': db.query(LegacyFile).count(),
+ 'FilesR': db.query(FilesR).count(),
+ 'FilesV': db.query(FilesV).count(),
+ 'FileNots': db.query(FileNots).count(),
+ 'Ledger': db.query(Ledger).count(),
+ 'Deposits': db.query(Deposits).count(),
+ 'LegacyPayment': db.query(LegacyPayment).count(),
+ },
+ 'specialized': {
+ 'PlanInfo': db.query(PlanInfo).count(),
+ 'Qdros': db.query(Qdros).count(),
+ 'Pensions': db.query(Pensions).count(),
+ 'PensionMarriage': db.query(PensionMarriage).count(),
+ 'PensionDeath': db.query(PensionDeath).count(),
+ 'PensionSchedule': db.query(PensionSchedule).count(),
+ 'PensionSeparate': db.query(PensionSeparate).count(),
+ 'PensionResults': db.query(PensionResults).count(),
+ },
+ 'modern': {
+ 'Client': db.query(Client).count(),
+ 'Phone': db.query(Phone).count(),
+ 'Case': db.query(Case).count(),
+ 'Transaction': db.query(Transaction).count(),
+ 'Payment': db.query(Payment).count(),
+ 'Document': db.query(Document).count(),
+ }
+ }
+
return templates.TemplateResponse("admin.html", {
"request": request,
"user": user,
"recent_imports": recent_imports,
"available_files": available_files,
+ "table_counts": table_counts,
"files_by_type": files_by_type
})
diff --git a/app/templates/admin.html b/app/templates/admin.html
index 13ad864..37aeb4f 100644
--- a/app/templates/admin.html
+++ b/app/templates/admin.html
@@ -137,6 +137,162 @@
{% endif %}
+
+ {% if table_counts %}
+
+
+
+
View record counts for all tables to track import progress:
+
+
+
+
+
Reference Tables
+
+
+
+
+ | Table |
+ Records |
+
+
+
+ {% for table_name, count in table_counts.reference.items() %}
+
+ |
+ {{ table_name }}
+ {% if count > 0 %}
+
+ {% endif %}
+ |
+
+
+ {{ "{:,}".format(count) }}
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
Core Data Tables
+
+
+
+
+ | Table |
+ Records |
+
+
+
+ {% for table_name, count in table_counts.core.items() %}
+
+ |
+ {{ table_name }}
+ {% if count > 0 %}
+
+ {% endif %}
+ |
+
+
+ {{ "{:,}".format(count) }}
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
Specialized Tables
+
+
+
+
+ | Table |
+ Records |
+
+
+
+ {% for table_name, count in table_counts.specialized.items() %}
+
+ |
+ {{ table_name }}
+ {% if count > 0 %}
+
+ {% endif %}
+ |
+
+
+ {{ "{:,}".format(count) }}
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
Modern Models
+
+
+
+
+ | Table |
+ Records |
+
+
+
+ {% for table_name, count in table_counts.modern.items() %}
+
+ |
+ {{ table_name }}
+ {% if count > 0 %}
+
+ {% endif %}
+ |
+
+
+ {{ "{:,}".format(count) }}
+
+ |
+
+ {% endfor %}
+
+
+
+
+
+
+
+
+
+
+ Legend:
+ Green = Has data imported |
+ Gray = No data yet |
+ = Table populated
+
+
+
+
+
+ {% endif %}
+