switch to debian in docker

This commit is contained in:
Mateusz Gruszczyński
2026-03-20 09:40:56 +01:00
parent 419c6fd0b5
commit 51da117ab4
6 changed files with 82 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ from pathlib import Path
import psutil
from flask import current_app
from sqlalchemy import inspect
from sqlalchemy.engine import make_url
from app.extensions import db
from app.models.audit_log import AuditLog
@@ -199,19 +200,52 @@ class SystemDataService:
continue
count = db.session.execute(db.select(db.func.count()).select_from(table)).scalar() or 0
table_rows.append({'table': table_name, 'rows': int(count)})
uri = current_app.config.get('SQLALCHEMY_DATABASE_URI', '')
sqlite_path = None
sqlite_size = None
db_driver = None
db_host = None
db_port = None
db_name = None
db_user = None
try:
url = make_url(uri)
db_driver = url.drivername
db_host = url.host
db_port = url.port
db_name = url.database
db_user = url.username
except Exception:
pass
if uri.startswith('sqlite:///') and not uri.endswith(':memory:'):
sqlite_path = uri.replace('sqlite:///', '', 1)
try:
sqlite_size = self._human_size(Path(sqlite_path).stat().st_size)
except FileNotFoundError:
sqlite_size = 'brak pliku'
if engine.name == 'sqlite':
db_label = 'SQLite'
elif engine.name == 'postgresql':
db_label = 'PostgreSQL'
elif engine.name == 'mysql':
db_label = 'MySQL'
else:
db_label = engine.name
table_rows_sorted = sorted(table_rows, key=lambda item: (-item['rows'], item['table']))
return {
'engine': engine.name,
'engine_label': db_label,
'driver': db_driver,
'uri': self._mask_uri(uri),
'host': db_host,
'port': db_port,
'database': db_name,
'username': db_user,
'tables_count': len(table_rows),
'sqlite_path': sqlite_path,
'sqlite_size': sqlite_size,