Просмотр исходного кода

♻️ (dashboard-v6): 管理后台评价表格的行 key 改用页内序号,类型按新规格重生

- 评价接口不再返回自增 id:表格只读,行 key 用分页偏移 + 页内序号;每页条数统一成 PAGE_SIZE
- admin-stats.md:提问人数按 account_type + account_id 去重

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
visuddhinanda 4 дней назад
Родитель
Сommit
30a492a26b

+ 1 - 1
dashboard-v6/documents/development/admin-stats.md

@@ -35,7 +35,7 @@
 | 指标 | 口径 | 来源 |
 |---|---|---|
 | 提问数 | 区间内开始的提问(`started_at`) | `agent_runs` |
-| 提问的人 | 登录用户按账号、游客按设备匿名 id 去重 | `agent_threads.account` |
+| 提问的人 | 登录用户按账号、游客按设备匿名 id 去重 | `agent_threads.account_type` + `account_id` |
 | 响应耗时 | 成功(status=ok)提问的 `latency_ms` P50 / P95 | `agent_runs` |
 | 拦截 / 出错 | status = denied(额度不足)与 error(已退积分);另列「未查额度放行」次数(2026-11 起 agent 不再放行,mint 不可用时回网络错误并记 denied;这一项只剩历史数据) | `agent_runs`、`agent_run_steps`(event · quota) |
 | 每日提问 | 按研究路径(question / term / passage / chat)堆叠 | `agent_runs.route` |

+ 8 - 5
dashboard-v6/src/api/schema.d.ts

@@ -34939,7 +34939,6 @@ export interface operations {
                 content: {
                     "application/json": {
                         data?: {
-                            id?: number;
                             message_id?: string;
                             rating?: number;
                             tags?: string[];
@@ -35001,7 +35000,8 @@ export interface operations {
                             run_id?: string;
                             thread_id?: string | null;
                             thread_title?: string | null;
-                            account_type?: string;
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
                             user?: {
                                 id?: string;
                                 nickName?: string;
@@ -35125,7 +35125,8 @@ export interface operations {
                             run_id?: string;
                             thread_id?: string | null;
                             thread_title?: string | null;
-                            account_type?: string;
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
                             user?: {
                                 id?: string;
                                 nickName?: string;
@@ -35797,7 +35798,8 @@ export interface operations {
                         data?: {
                             run_id?: string;
                             thread_id?: string;
-                            account_type?: string;
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
                             created_at?: string;
                         };
                     };
@@ -35813,7 +35815,8 @@ export interface operations {
                         data?: {
                             run_id?: string;
                             thread_id?: string;
-                            account_type?: string;
+                            /** @enum {string} */
+                            account_type?: "user" | "guest";
                             created_at?: string;
                         };
                     };

+ 9 - 4
dashboard-v6/src/features/admin-stats/AgentFeedbackTable.tsx

@@ -12,6 +12,8 @@ import dayjs from "dayjs";
 import type { AgentFeedbackItem } from "../../api/adminStats";
 import { useAgentFeedback } from "../../hooks/useAdminStats";
 import AgentRunDrawer from "./AgentRunDrawer";
+
+const PAGE_SIZE = 20;
 import { useT } from "./helpers";
 
 const UP_TAGS = ["accurate", "useful_citations", "clear", "inspiring"];
@@ -26,11 +28,15 @@ const AgentFeedbackTable = () => {
   const [runId, setRunId] = useState<string | null>(null);
   const { data, loading } = useAgentFeedback({
     page,
-    per_page: 20,
+    per_page: PAGE_SIZE,
     ...(filters.rating ? { "filter[rating]": String(filters.rating) as "1" | "-1" } : {}),
     ...(filters.tag ? { "filter[tag]": filters.tag } : {}),
   });
 
+  // 评价没有对外的 id(接口不返回自增主键,也没有按单条评价查询的接口):
+  // 表格只读,行 key 用「分页偏移 + 页内序号」即可
+  const rows = (data?.data ?? []).map((item, i) => ({ ...item, key: (page - 1) * PAGE_SIZE + i }));
+
   const columns: ColumnsType<AgentFeedbackItem> = [
     {
       title: t("admin.stats.runs.time"),
@@ -101,12 +107,11 @@ const AgentFeedbackTable = () => {
     <>
       <Table<AgentFeedbackItem>
         size="small"
-        rowKey="id"
         columns={columns}
-        dataSource={data?.data ?? []}
+        dataSource={rows}
         loading={loading}
         scroll={{ x: 1000 }}
-        pagination={{ current: page, pageSize: 20, total: data?.meta?.total ?? 0, showSizeChanger: false, onChange: setPage }}
+        pagination={{ current: page, pageSize: PAGE_SIZE, total: data?.meta?.total ?? 0, showSizeChanger: false, onChange: setPage }}
         onChange={(_, f, __, extra) => {
           // 翻页也会触发 onChange:只在筛选时重置筛选条件与页码
           if (extra.action !== "filter") return;