feat: 增强管理员工作台聊天统计看板

- 工作台接入聊天消息总数、会话总数、活跃智能体数、趋势与 Top5 排行

- dashboard 接口新增 chatStatus 与聊天统计字段,分析库不可用时明确降级

- today 维度按小时聚合聊天趋势,并补充后端查询与测试覆盖
This commit is contained in:
2026-04-19 17:40:01 +08:00
parent 1d8b9d9662
commit 5827ecde42
16 changed files with 1206 additions and 90 deletions

View File

@@ -0,0 +1,18 @@
ALTER TABLE dws_chat_assistant_day
ADD COLUMN IF NOT EXISTS `tenant_id` UInt64 DEFAULT 0 AFTER `dimension_id`;
ALTER TABLE dws_chat_assistant_day DELETE WHERE `tenant_id` = 0;
INSERT INTO dws_chat_assistant_day
SELECT
toDate(l.created) AS stat_date,
l.assistant_id AS dimension_id,
ifNull(s.tenant_id, toUInt64(0)) AS tenant_id,
uniqExact(l.session_id) AS session_count,
count() AS message_count
FROM ods_chat_log l
LEFT JOIN (
SELECT id, tenant_id
FROM ods_chat_session FINAL
) s ON s.id = l.session_id
GROUP BY stat_date, dimension_id, tenant_id;