260323 function add report chat and front
This commit is contained in:
1 parent
605317c2b2
commit
5e8ea03b6c
16 files changed
+2351
-100
No files matched your search
@@ -0,0 +1,25 @@
|
||||
from app import create_app, db
|
||||
from app.models import ChatLog, User
|
||||
from sqlalchemy import func
|
||||
|
||||
app = create_app('development')
|
||||
with app.app_context():
|
||||
print('=== 数据库中的用户 ===')
|
||||
users = db.session.query(User).all()
|
||||
for u in users:
|
||||
print(f'id={u.id}, username={u.username}, role={u.role}')
|
||||
|
||||
print()
|
||||
print('=== 各用户对 Agent 3 的会话统计 ===')
|
||||
for uid in [1, 2, 3, 4, 5]:
|
||||
count = db.session.query(func.count(ChatLog.id)).filter(
|
||||
ChatLog.user_id == uid,
|
||||
ChatLog.agent_id == 3
|
||||
).scalar()
|
||||
print(f'user_id={uid}: {count} logs')
|
||||
|
||||
print()
|
||||
print('=== ChatLog 样本 (Agent 3) ===')
|
||||
logs = db.session.query(ChatLog).filter(ChatLog.agent_id == 3).order_by(ChatLog.created_at.desc()).limit(5).all()
|
||||
for log in logs:
|
||||
print(f'user_id={log.user_id}, conv_id={log.conversation_id}, query={log.query[:40]}...')
|
||||
Reference in new issue
Block a user