poprawnie zliczanie rekordow w bazie
This commit is contained in:
18
app.py
18
app.py
@@ -355,6 +355,16 @@ def enrich_list_data(l):
|
||||
return l
|
||||
|
||||
|
||||
def get_total_records():
|
||||
total = 0
|
||||
inspector = inspect(db.engine)
|
||||
with db.engine.connect() as conn:
|
||||
for table_name in inspector.get_table_names():
|
||||
count = conn.execute(text(f"SELECT COUNT(*) FROM {table_name}")).scalar()
|
||||
total += count
|
||||
return total
|
||||
|
||||
|
||||
def save_resized_image(file, path):
|
||||
try:
|
||||
image = Image.open(file)
|
||||
@@ -1844,13 +1854,7 @@ def admin_panel():
|
||||
inspector = inspect(db_engine)
|
||||
table_count = len(inspector.get_table_names())
|
||||
|
||||
record_total = (
|
||||
db.session.query(func.count(User.id)).scalar()
|
||||
+ db.session.query(func.count(ShoppingList.id)).scalar()
|
||||
+ db.session.query(func.count(Item.id)).scalar()
|
||||
+ db.session.query(func.count(Receipt.id)).scalar()
|
||||
+ db.session.query(func.count(Expense.id)).scalar()
|
||||
)
|
||||
record_total = get_total_records()
|
||||
|
||||
uptime_minutes = int(
|
||||
(datetime.now(timezone.utc) - app_start_time).total_seconds() // 60
|
||||
|
Reference in New Issue
Block a user