Admin: KI-Anfragen nach Quelle aufschlüsseln (cloud/local/luna)
- ki_daily_calls: PK auf (user_id, date, source) erweitert + Index; Migration baut Tabelle mit neuer Struktur neu auf, behält Altdaten als 'cloud' - ki.py: return_source=True-Parameter gibt (text, 'cloud'|'local') zurück - training.py: ki_source aus ki.complete() auslesen, in DB speichern - social.py: _ki_complete_tracked() zählt Luna-Anfragen mit source='luna'; alle Content-Endpoints (generate, evaluate, training-tip, breed-of-day, pflege-tipp) nutzen tracking-Variante - admin.py: Stats aufgeteilt in ki_cloud/ki_local/ki_luna je heute+Monat - admin.js: KI-Karte zeigt 9 Zeilen mit ☁️ Claude / 🖥️ LM Studio / 🌙 Luna - SW by-v359, APP_VER 344
This commit is contained in:
parent
74b6c03bb3
commit
8d5c7a19b1
6 changed files with 136 additions and 33 deletions
|
|
@ -160,8 +160,30 @@ async def stats(user=Depends(require_mod)):
|
|||
ki_users_today = conn.execute(
|
||||
"SELECT COUNT(DISTINCT user_id) FROM ki_daily_calls WHERE date=DATE('now')"
|
||||
).fetchone()[0]
|
||||
# Aufschlüsselung nach Quelle (heute)
|
||||
_src_today = {
|
||||
r[0]: r[1] for r in conn.execute(
|
||||
"SELECT source, COALESCE(SUM(count),0) FROM ki_daily_calls "
|
||||
"WHERE date=DATE('now') GROUP BY source"
|
||||
).fetchall()
|
||||
}
|
||||
ki_cloud_today = _src_today.get("cloud", 0)
|
||||
ki_local_today = _src_today.get("local", 0)
|
||||
ki_luna_today = _src_today.get("luna", 0)
|
||||
# Aufschlüsselung nach Quelle (Monat)
|
||||
_src_month = {
|
||||
r[0]: r[1] for r in conn.execute(
|
||||
"SELECT source, COALESCE(SUM(count),0) FROM ki_daily_calls "
|
||||
"WHERE date>=DATE('now','start of month') GROUP BY source"
|
||||
).fetchall()
|
||||
}
|
||||
ki_cloud_month = _src_month.get("cloud", 0)
|
||||
ki_local_month = _src_month.get("local", 0)
|
||||
ki_luna_month = _src_month.get("luna", 0)
|
||||
except Exception:
|
||||
ki_today = ki_month = ki_users_today = 0
|
||||
ki_cloud_today = ki_local_today = ki_luna_today = 0
|
||||
ki_cloud_month = ki_local_month = ki_luna_month = 0
|
||||
|
||||
# Social Media Tracking
|
||||
try:
|
||||
|
|
@ -217,6 +239,12 @@ async def stats(user=Depends(require_mod)):
|
|||
"ki_today": ki_today,
|
||||
"ki_month": ki_month,
|
||||
"ki_users_today": ki_users_today,
|
||||
"ki_cloud_today": ki_cloud_today,
|
||||
"ki_local_today": ki_local_today,
|
||||
"ki_luna_today": ki_luna_today,
|
||||
"ki_cloud_month": ki_cloud_month,
|
||||
"ki_local_month": ki_local_month,
|
||||
"ki_luna_month": ki_luna_month,
|
||||
"social_total": social_total,
|
||||
"social_published": social_published,
|
||||
"social_scheduled": social_scheduled,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue