feat(tasks): 任务列表新增「运行中 Worker」列
TaskListMetricsAll 增加一个 LATERAL 子查询统计 kind='intent' 且 state='running' 的节点数,随 TaskDTO.in_flight 一并返回,口径与任务 详情页概览的「运行中 Worker」完全一致。列表页在「目标进度」后新增该 列,无运行中 Worker 时显示 0。
This commit is contained in:
1 parent
4fba36b73d
commit
f270ca66bc
4 files changed
+22
-4
No files matched your search
+12
-4
@@ -1064,9 +1064,10 @@ type GoalCounts struct{ Total, Met int }
|
||||
|
||||
// TaskListMetrics contains the aggregates rendered in task lists.
|
||||
type TaskListMetrics struct {
|
||||
Tokens TokenUsage
|
||||
LastActivity int64
|
||||
Goals GoalCounts
|
||||
Tokens TokenUsage
|
||||
LastActivity int64
|
||||
Goals GoalCounts
|
||||
RunningIntents int // kind='intent' 且 state='running' 的条数,即运行中 Worker 数
|
||||
}
|
||||
|
||||
// TaskListMetricsAll returns list aggregates for every live task in one query.
|
||||
@@ -1081,7 +1082,8 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) {
|
||||
COALESCE(token_metrics.cache_write_tokens,0),
|
||||
COALESCE(latest_activity.created_at,0),
|
||||
COALESCE(goal_metrics.total,0),
|
||||
COALESCE(goal_metrics.met,0)
|
||||
COALESCE(goal_metrics.met,0),
|
||||
COALESCE(intent_metrics.running,0)
|
||||
FROM tasks task
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT SUM(input_tokens) AS input_tokens,
|
||||
@@ -1104,6 +1106,11 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) {
|
||||
FROM exploration_nodes
|
||||
WHERE exploration_id=task.exploration_id AND kind='goal'
|
||||
) goal_metrics ON true
|
||||
LEFT JOIN LATERAL (
|
||||
SELECT COUNT(*) AS running
|
||||
FROM exploration_nodes
|
||||
WHERE exploration_id=task.exploration_id AND kind='intent' AND state='running'
|
||||
) intent_metrics ON true
|
||||
WHERE task.deleted_at IS NULL`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1122,6 +1129,7 @@ func (d *DB) TaskListMetricsAll() (map[int64]TaskListMetrics, error) {
|
||||
&metrics.LastActivity,
|
||||
&metrics.Goals.Total,
|
||||
&metrics.Goals.Met,
|
||||
&metrics.RunningIntents,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user