v1.8.25: fix memory count — read from Qdrant mem0_memory not empty PG table

This commit is contained in:
2026-05-28 22:18:12 +00:00
parent a508239cba
commit 1c142668cf
2 changed files with 8 additions and 2 deletions
+8 -2
View File
@@ -314,7 +314,10 @@ def stats():
with conn.cursor() as cur: with conn.cursor() as cur:
cur.execute("SELECT COUNT(*) FROM books"); books = cur.fetchone()[0] cur.execute("SELECT COUNT(*) FROM books"); books = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM conversations"); convos = cur.fetchone()[0] cur.execute("SELECT COUNT(*) FROM conversations"); convos = cur.fetchone()[0]
cur.execute("SELECT COUNT(*) FROM memory"); memories = cur.fetchone()[0] try:
mi = httpx.get("http://qdrant:6333/collections/mem0_memory", timeout=2).json()
memories = mi.get("result",{}).get("points_count",0)
except: memories = 0
except Exception as e: except Exception as e:
print(f"Stats db error: {e}") print(f"Stats db error: {e}")
books = convos = memories = 0 books = convos = memories = 0
@@ -455,7 +458,10 @@ def admin_overview(_=Depends(require_admin)):
with conn.cursor(cursor_factory=RealDictCursor) as cur: with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute("SELECT COUNT(*) as total FROM books"); books = cur.fetchone()["total"] cur.execute("SELECT COUNT(*) as total FROM books"); books = cur.fetchone()["total"]
cur.execute("SELECT COUNT(*) as total FROM conversations"); convos = cur.fetchone()["total"] cur.execute("SELECT COUNT(*) as total FROM conversations"); convos = cur.fetchone()["total"]
cur.execute("SELECT COUNT(*) as total FROM memory"); memories = cur.fetchone()["total"] try:
mi = httpx.get("http://qdrant:6333/collections/mem0_memory", timeout=2).json()
memories = mi.get("result",{}).get("points_count",0)
except: memories = 0
cur.execute("SELECT COUNT(DISTINCT session_id) as total FROM conversations"); unique_users = cur.fetchone()["total"] cur.execute("SELECT COUNT(DISTINCT session_id) as total FROM conversations"); unique_users = cur.fetchone()["total"]
cur.execute("SELECT llm_used, COUNT(*) as cnt FROM conversations GROUP BY llm_used ORDER BY cnt DESC") cur.execute("SELECT llm_used, COUNT(*) as cnt FROM conversations GROUP BY llm_used ORDER BY cnt DESC")
llm_usage = cur.fetchall() llm_usage = cur.fetchall()
Binary file not shown.