mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-05 13:01:50 +08:00
feat: search approval history by content and date
This commit is contained in:
1 parent
e33eedeb17
commit
2f2b78cc78
9 files changed
+255
-11
No files matched your search
+4
-1
@@ -84,7 +84,6 @@ import type {
|
||||
SSTask,
|
||||
Stats,
|
||||
Task,
|
||||
TaskSchedule,
|
||||
TaskArchive,
|
||||
TaskArchivePage,
|
||||
TaskAssetMutation,
|
||||
@@ -94,6 +93,7 @@ import type {
|
||||
TaskGoal,
|
||||
TaskLLMResolutions,
|
||||
TaskNode,
|
||||
TaskSchedule,
|
||||
TaskScopeRow,
|
||||
TaskTemplate,
|
||||
TokenTotal,
|
||||
@@ -243,6 +243,9 @@ function interceptPageQuery(page: number, size: number, filter: InterceptApprova
|
||||
const query = new URLSearchParams({ page: String(page), size: String(size) });
|
||||
if (filter.status) query.set("status", filter.status);
|
||||
if (filter.decision_source) query.set("decision_source", filter.decision_source);
|
||||
if (filter.q?.trim()) query.set("q", filter.q.trim());
|
||||
if (filter.from) query.set("from", filter.from);
|
||||
if (filter.to) query.set("to", filter.to);
|
||||
return query.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -2461,18 +2461,37 @@ function route(m: string, path: string, seg: string[], q: URLSearchParams, b: Re
|
||||
if (path === "/intercept/history" || (seg[0] === "intercept" && seg[1] === "task")) {
|
||||
const status = q.get("status") || "";
|
||||
const decisionSource = q.get("decision_source") || "";
|
||||
const search = (q.get("q") || "").trim();
|
||||
const from = q.get("from") || "";
|
||||
const to = q.get("to") || "";
|
||||
if (status && !["pending", "allowed", "denied", "timeout"].includes(status)) throw new Error("无效审批状态");
|
||||
if (decisionSource && !["model", "rule", "unknown"].includes(decisionSource)) throw new Error("无效判定来源");
|
||||
if ([...search].length > 200) throw new Error("搜索关键词不能超过 200 个字符");
|
||||
if (search.startsWith("#") && !/^#[1-9]\d*$/.test(search)) throw new Error("审批编号必须为 # 后接正整数");
|
||||
for (const value of [from, to]) {
|
||||
if (value && !/^\d{4}-\d{2}-\d{2}$/.test(value)) throw new Error("日期必须是 YYYY-MM-DD");
|
||||
}
|
||||
if (from && to && from > to) throw new Error("开始日期不能晚于结束日期");
|
||||
const filtered = mockInterceptHistory.filter((row) => {
|
||||
const source =
|
||||
row.decision_source || (row.rule_id ? "rule" : row.reason?.startsWith("[模型]") ? "model" : "unknown");
|
||||
let source = row.decision_source;
|
||||
if (!source) {
|
||||
if (row.rule_id) source = "rule";
|
||||
else if (row.reason?.startsWith("[模型]")) source = "model";
|
||||
else source = "unknown";
|
||||
}
|
||||
const haystack = JSON.stringify({ ...row, audit: mockInterceptDetails[row.id] ?? null }).toLowerCase();
|
||||
const day = row.created_at.slice(0, 10);
|
||||
return (
|
||||
(seg[1] !== "task" || row.task_id === decodeURIComponent(seg[2])) &&
|
||||
(!status || row.status === status) &&
|
||||
(!decisionSource || source === decisionSource)
|
||||
(!decisionSource || source === decisionSource) &&
|
||||
(!from || day >= from) &&
|
||||
(!to || day <= to) &&
|
||||
(!search ||
|
||||
(search.startsWith("#") ? row.id === Number(search.slice(1)) : haystack.includes(search.toLowerCase())))
|
||||
);
|
||||
});
|
||||
if (!q.has("page") && !q.has("size") && !status && !decisionSource)
|
||||
if (!q.has("page") && !q.has("size") && !status && !decisionSource && !search && !from && !to)
|
||||
return { items: filtered, total: filtered.length };
|
||||
const page = Math.max(1, Number(q.get("page")) || 1);
|
||||
const size = Math.min(100, Math.max(1, Number(q.get("size")) || 20));
|
||||
|
||||
@@ -1386,6 +1386,9 @@ export interface JudgeUsage {
|
||||
export interface InterceptApprovalFilter {
|
||||
status?: InterceptPending["status"];
|
||||
decision_source?: "rule" | "model" | "unknown";
|
||||
q?: string;
|
||||
from?: string;
|
||||
to?: string;
|
||||
}
|
||||
|
||||
// InterceptApprovalRow enriches InterceptPending with conversation/task and rule context.
|
||||
|
||||
Reference in new issue
Block a user