Session zu Aktive Nutzung im Dashboard
Dieser Commit ist enthalten in:
@@ -32,10 +32,38 @@ def dashboard():
|
||||
cur.execute("SELECT COUNT(*) FROM customers")
|
||||
total_customers = cur.fetchone()[0] if cur.rowcount > 0 else 0
|
||||
|
||||
# Anzahl aktiver Sessions
|
||||
# Anzahl aktiver Sessions (Admin-Panel)
|
||||
cur.execute("SELECT COUNT(*) FROM sessions WHERE is_active = true")
|
||||
active_sessions = cur.fetchone()[0] if cur.rowcount > 0 else 0
|
||||
|
||||
# Aktive Nutzung (Kunden-Software) - Lizenzen mit Heartbeats in den letzten 15 Minuten
|
||||
active_usage = 0
|
||||
try:
|
||||
# Prüfe ob Tabelle existiert
|
||||
cur.execute("""
|
||||
SELECT EXISTS (
|
||||
SELECT FROM information_schema.tables
|
||||
WHERE table_name = 'license_heartbeats'
|
||||
)
|
||||
""")
|
||||
table_exists = cur.fetchone()[0]
|
||||
|
||||
if table_exists:
|
||||
cur.execute("""
|
||||
SELECT COUNT(DISTINCT license_id)
|
||||
FROM license_heartbeats
|
||||
WHERE timestamp > NOW() - INTERVAL '15 minutes'
|
||||
""")
|
||||
active_usage = cur.fetchone()[0] if cur.rowcount > 0 else 0
|
||||
except Exception as e:
|
||||
# Bei Fehler einfach 0 verwenden
|
||||
current_app.logger.warning(f"Could not get active usage: {str(e)}")
|
||||
# Rollback der fehlgeschlagenen Transaktion
|
||||
conn.rollback()
|
||||
# Neue Transaktion starten
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
# Top 10 Lizenzen - vereinfacht
|
||||
cur.execute("""
|
||||
SELECT
|
||||
@@ -69,7 +97,8 @@ def dashboard():
|
||||
stats = {
|
||||
'total_customers': total_customers,
|
||||
'total_licenses': active_licenses,
|
||||
'active_sessions': active_sessions,
|
||||
'active_sessions': active_sessions, # Admin-Panel Sessions
|
||||
'active_usage': active_usage, # Aktive Kunden-Nutzung
|
||||
'active_licenses': active_licenses,
|
||||
'full_licenses': 0,
|
||||
'test_licenses': 0,
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren