fix: report

This commit is contained in:
HTEWJ\26070045 committed 2026-09-09 14:19:41 +08:00
1 parent 07e83132c0
commit 4445ff68d4
46 files changed
+3904 -897

No files matched your search

@@ -10,7 +10,7 @@ from __future__ import annotations
from sqlalchemy import func
from app import db
from app.models import Agent, ChatLog, Feedback, PermissionRequest, User
from app.models import Agent, ChatLog, Feedback, User
def compute_dashboard_summary() -> dict:
@@ -32,26 +32,12 @@ def compute_dashboard_summary() -> dict:
}
def compute_dashboard_badges() -> dict:
"""
聚合侧栏角标所需的待办数量。
Returns:
pending_approvals、pending_requests。
"""
pending_requests = db.session.query(func.count(PermissionRequest.id)).filter_by(status='pending').scalar() or 0
return {
'pending_requests': pending_requests,
}
def compute_legacy_dashboard_stats() -> dict:
"""遗留 /dashboard 接口响应(summary + badges 字段名兼容早期前端)。"""
summary = compute_dashboard_summary()
badges = compute_dashboard_badges()
return {
'total_users': summary['user_count'],
'active_agents': summary['agent_count'],
'total_conversations': summary['total_conversations'],
'avg_score': summary['avg_score'],
'pending_requests': badges['pending_requests'],
}