Dockerfile 运行阶段补齐 dws_dingtalk_scan(F12),并新增 runtime-scripts 门禁 做脚本依赖闭包正负例;就绪探测每次解析当前端点/绑定/凭据并区分 404、未配置、 不可达(F13);路由写入来源路径与父目录,历史空值仅按同连接同 item 的意图读时 补齐(F14);目标筛选显示短 ID 与当前绑定/历史并提供快捷筛选(F15);刷新终态 移除后台运行、展示失败时间/旧快照/脱敏原因/作业 ID 与重试(F16)。 验证:make verify 17 项全过(identity 本地按设计 skipped);一次性 schema 的 Monitor 目录/路由集成用例通过;8088 部署与真实 UI 验收仍由父会话执行。
This commit is contained in:
@@ -16,23 +16,27 @@ type MonitorTaskEvent struct {
|
||||
Detail string `json:"detail"`
|
||||
}
|
||||
type MonitorTask struct {
|
||||
History []MonitorTaskEvent `json:"history"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Path string `json:"path"`
|
||||
SourceID string `json:"source_id"`
|
||||
SourceName string `json:"source_name"`
|
||||
TargetScope string `json:"target_scope"`
|
||||
TargetKB string `json:"target_kb"`
|
||||
Action string `json:"action"`
|
||||
Stage string `json:"stage"`
|
||||
Status string `json:"status"`
|
||||
Detail string `json:"detail"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
RetryKind string `json:"retry_kind"`
|
||||
FailureID string `json:"failure_id"`
|
||||
RetryCount int `json:"retry_count"`
|
||||
VersionID string `json:"version_id"`
|
||||
History []MonitorTaskEvent `json:"history"`
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Path string `json:"path"`
|
||||
// NodeID/ParentNodeID let the UI return to the exact source directory;
|
||||
// both come from the catalog snapshot bound to THIS source item.
|
||||
NodeID string `json:"node_id"`
|
||||
ParentNodeID string `json:"parent_node_id"`
|
||||
SourceID string `json:"source_id"`
|
||||
SourceName string `json:"source_name"`
|
||||
TargetScope string `json:"target_scope"`
|
||||
TargetKB string `json:"target_kb"`
|
||||
Action string `json:"action"`
|
||||
Stage string `json:"stage"`
|
||||
Status string `json:"status"`
|
||||
Detail string `json:"detail"`
|
||||
UpdatedAt string `json:"updated_at"`
|
||||
RetryKind string `json:"retry_kind"`
|
||||
FailureID string `json:"failure_id"`
|
||||
RetryCount int `json:"retry_count"`
|
||||
VersionID string `json:"version_id"`
|
||||
}
|
||||
type MonitorTaskPage struct {
|
||||
Items []MonitorTask `json:"items"`
|
||||
@@ -42,10 +46,18 @@ type MonitorTaskPage struct {
|
||||
Sources []MonitorOption `json:"sources"`
|
||||
Targets []MonitorOption `json:"targets"`
|
||||
Retryable int `json:"retryable"`
|
||||
// Bindings is the effective (persisted, env-fallback aware) target for each
|
||||
// scope. The UI marks rows/options against it; counts stay this page's totals.
|
||||
Bindings MonitorBindings `json:"bindings"`
|
||||
}
|
||||
type MonitorOption struct {
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ID string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Scope string `json:"scope,omitempty"`
|
||||
}
|
||||
type MonitorBindings struct {
|
||||
Internal string `json:"internal"`
|
||||
External string `json:"external"`
|
||||
}
|
||||
|
||||
// Reduce publication versions before filtering; totals and pages share one snapshot.
|
||||
@@ -62,7 +74,11 @@ const monitorTasksCTE = `WITH history_publications AS (
|
||||
WHERE p.superseded_at IS NULL
|
||||
ORDER BY v.source_item_id,p.test_kb_id,p.created_at DESC,p.id DESC
|
||||
), base AS (
|
||||
SELECT p.id,si.title,si.normalized_path AS path,c.id AS source_id,c.name AS source_name,
|
||||
SELECT p.id,si.title,
|
||||
COALESCE(NULLIF(si.normalized_path,''),ci.relative_path,'') AS path,
|
||||
COALESCE(NULLIF(si.parent_external_id,''),cn.parent_node_id,'') AS parent_node_id,
|
||||
COALESCE(ci.node_id,'') AS node_id,
|
||||
c.id AS source_id,c.name AS source_name,
|
||||
p.target_scope,p.test_kb_id AS target_kb,p.source_item_version_id AS version_id,p.retry_count,
|
||||
GREATEST(p.updated_at,j.updated_at,f.created_at) AS updated_at,
|
||||
p.processing_state,p.ingest_state,p.retrieval_state,p.last_error,p.knowledge_id,
|
||||
@@ -72,6 +88,13 @@ const monitorTasksCTE = `WITH history_publications AS (
|
||||
COALESCE(j.type,'') AS job_type,COALESCE(j.state,'') AS job_state,COALESCE(j.attempt,0) AS job_attempt,j.available_at,
|
||||
COALESCE(f.id,'') AS failure_id,COALESCE(f.job_type,'') AS failure_type,COALESCE(NULLIF(f.last_error,''),f.error_code,'') AS failure_error
|
||||
FROM latest p JOIN source_items si ON si.id=p.source_item_id JOIN source_connections c ON c.id=si.source_connection_id
|
||||
-- 历史行路径为空时,只用「同一连接 + 同一 item」的取件意图补齐:不按文件名猜配。
|
||||
LEFT JOIN LATERAL(SELECT intent.relative_path,intent.node_id FROM catalog_import_intents intent
|
||||
WHERE intent.source_item_id=si.id AND intent.source_connection_id=si.source_connection_id
|
||||
ORDER BY intent.updated_at DESC,intent.node_id LIMIT 1) ci ON TRUE
|
||||
LEFT JOIN LATERAL(SELECT node.parent_node_id FROM source_catalog_heads head
|
||||
JOIN source_catalog_nodes node ON node.snapshot_id=head.snapshot_id
|
||||
WHERE head.source_connection_id=si.source_connection_id AND node.node_id=ci.node_id LIMIT 1) cn ON TRUE
|
||||
LEFT JOIN content_objects co ON co.id=p.content_object_id
|
||||
LEFT JOIN LATERAL(SELECT j.type,j.state,j.attempt,j.available_at,j.updated_at FROM jobs j WHERE
|
||||
(j.payload->>'publication_id'=p.id OR (j.type='artifact.fetch' AND j.payload->>'version_id'=p.source_item_version_id))
|
||||
@@ -101,7 +124,7 @@ const monitorTasksCTE = `WITH history_publications AS (
|
||||
ELSE 'waiting' END AS stage
|
||||
FROM base
|
||||
), projected AS (
|
||||
SELECT id,title,path,source_id,source_name,target_scope,target_kb,version_id,retry_count,updated_at,action,stage,status,failure_id,
|
||||
SELECT id,title,path,parent_node_id,node_id,source_id,source_name,target_scope,target_kb,version_id,retry_count,updated_at,action,stage,status,failure_id,
|
||||
CASE WHEN status<>'attention' THEN ''
|
||||
WHEN action='remove' THEN CASE WHEN job_type='test.remove' AND job_state='failed' AND retrieval_state IN ('failed','disabling') AND policy_state='blocked' THEN 'remove' ELSE '' END
|
||||
WHEN failure_type='artifact.fetch' THEN 'fetch'
|
||||
@@ -130,7 +153,7 @@ func (s *Store) ListMonitorTasks(ctx context.Context, f MonitorTaskFilter) (Moni
|
||||
return MonitorTaskPage{}, errors.New("invalid monitor pagination")
|
||||
}
|
||||
var raw []byte
|
||||
err := s.db.QueryRow(ctx, monitorTasksCTE+`SELECT jsonb_build_object('items',COALESCE((SELECT jsonb_agg(to_jsonb(x)||jsonb_build_object('history',COALESCE((SELECT jsonb_agg(e ORDER BY e.at DESC,e.kind,e.detail) FROM (SELECT * FROM history_events ORDER BY at DESC,kind,detail LIMIT 50)e),'[]'::jsonb)) ORDER BY x.updated_at DESC,x.id) FROM (SELECT * FROM filtered ORDER BY updated_at DESC,id LIMIT $8 OFFSET $9)x),'[]'::jsonb),'total',(SELECT count(*) FROM filtered),'limit',$8::int,'offset',$9::int,'retryable',(SELECT count(*) FROM filtered WHERE retry_kind<>''),'sources',COALESCE((SELECT jsonb_agg(x ORDER BY x.name) FROM (SELECT DISTINCT source_id AS id,source_name AS name FROM projected)x),'[]'::jsonb),'targets',COALESCE((SELECT jsonb_agg(x ORDER BY x.name) FROM (SELECT DISTINCT target_kb AS id,target_kb AS name FROM projected)x),'[]'::jsonb))`, f.Search, f.Source, f.Scope, f.Action, f.Status, f.Stage, f.ID, f.Limit, f.Offset, f.Target, f.Since, f.Until).Scan(&raw)
|
||||
err := s.db.QueryRow(ctx, monitorTasksCTE+`SELECT jsonb_build_object('items',COALESCE((SELECT jsonb_agg(to_jsonb(x)||jsonb_build_object('history',COALESCE((SELECT jsonb_agg(e ORDER BY e.at DESC,e.kind,e.detail) FROM (SELECT * FROM history_events ORDER BY at DESC,kind,detail LIMIT 50)e),'[]'::jsonb)) ORDER BY x.updated_at DESC,x.id) FROM (SELECT * FROM filtered ORDER BY updated_at DESC,id LIMIT $8 OFFSET $9)x),'[]'::jsonb),'total',(SELECT count(*) FROM filtered),'limit',$8::int,'offset',$9::int,'retryable',(SELECT count(*) FROM filtered WHERE retry_kind<>''),'sources',COALESCE((SELECT jsonb_agg(x ORDER BY x.name) FROM (SELECT DISTINCT source_id AS id,source_name AS name FROM projected)x),'[]'::jsonb),'targets',COALESCE((SELECT jsonb_agg(x ORDER BY x.scope,x.id) FROM (SELECT target_kb AS id,MIN(target_scope) AS scope FROM projected GROUP BY target_kb)x),'[]'::jsonb))`, f.Search, f.Source, f.Scope, f.Action, f.Status, f.Stage, f.ID, f.Limit, f.Offset, f.Target, f.Since, f.Until).Scan(&raw)
|
||||
if err != nil {
|
||||
return MonitorTaskPage{}, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user