diff --git a/desktop/controlplane-next/frontend/src/views/overview/index.vue b/desktop/controlplane-next/frontend/src/views/overview/index.vue
index 3757056..7e8afe3 100644
--- a/desktop/controlplane-next/frontend/src/views/overview/index.vue
+++ b/desktop/controlplane-next/frontend/src/views/overview/index.vue
@@ -38,7 +38,8 @@ const trendData = computed(() => {
return [
{ name: '触发', data: trend.map((t: any) => t.runs), showAreaColor: true },
{ name: '成功', data: trend.map((t: any) => t.success) },
- { name: '失败', data: trend.map((t: any) => t.failed) }
+ { name: '失败', data: trend.map((t: any) => t.failed) },
+ { name: '取消', data: trend.map((t: any) => t.cancelled) }
]
})
@@ -101,24 +102,25 @@ onMounted(load)
-
-
-
-
-
-
+
+
diff --git a/desktop/controlplane-next/frontend/src/views/stats/index.vue b/desktop/controlplane-next/frontend/src/views/stats/index.vue
index 16f4fe9..29c2815 100644
--- a/desktop/controlplane-next/frontend/src/views/stats/index.vue
+++ b/desktop/controlplane-next/frontend/src/views/stats/index.vue
@@ -16,14 +16,20 @@
return [
{ name: '触发', data: trend.map((t: any) => t.runs), showAreaColor: true },
{ name: '成功', data: trend.map((t: any) => t.success) },
- { name: '失败', data: trend.map((t: any) => t.failed) }
+ { name: '失败', data: trend.map((t: any) => t.failed) },
+ { name: '取消', data: trend.map((t: any) => t.cancelled) }
]
})
const trendX = computed(() => (data.value.trend || []).map((t: any) => t.day))
+ /** 运行总次数 = 终态记录数(成功+失败+取消),三者相加严格等于它 */
const totalRuns = computed(() => data.value.runs?.total || 0)
+ const triggeredRuns = computed(() => data.value.runs?.triggered || 0)
const successCount = computed(() => data.value.runs?.success || 0)
const failedCount = computed(() => data.value.runs?.failed || 0)
+ /** 用户取消(强制停止 / 排队取消 / 排队超时 / 客户端退出)不算失败 */
+ const cancelledCount = computed(() => data.value.runs?.cancelled || 0)
+ /** 成功率分母:只算成功+失败,取消不进分母(壳子上报口径) */
const finishedCount = computed(() => successCount.value + failedCount.value)
const successRate = computed(() => {
@@ -38,7 +44,8 @@
const ringData = computed(() => [
{ name: '成功', value: successCount.value },
- { name: '失败', value: failedCount.value }
+ { name: '失败', value: failedCount.value },
+ { name: '取消', value: cancelledCount.value }
])
const avgDuration = computed(() => {
@@ -156,10 +163,16 @@
失败 {{ fmtNum(failedCount) }}
+
+ 取消 {{ fmtNum(cancelledCount) }}
+
平均耗时 {{ avgDuration }}
+
+ 总次数 = 成功 + 失败 + 取消;触发上报 {{ fmtNum(triggeredRuns) }} 次(含排队取消、仍在运行)
+
@@ -213,7 +226,7 @@
近 14 天运行趋势
触发 = start · 成功 = done/success · 失败 = error/failed触发 = start · 成功 = done/success · 失败 = error/failed · 取消 = cancelled
近 14 天
@@ -236,7 +249,7 @@
{{ fmtNum(successCount) }}
- {{ finishedCount ? Math.round((successCount / finishedCount) * 100) : 0 }}%
+ {{ totalRuns ? Math.round((successCount / totalRuns) * 100) : 0 }}%
@@ -263,7 +276,16 @@
{{ fmtNum(failedCount) }}
- {{ finishedCount ? Math.round((failedCount / finishedCount) * 100) : 0 }}%
+ {{ totalRuns ? Math.round((failedCount / totalRuns) * 100) : 0 }}%
+
+
+
+
+ 取消
+
+ {{ fmtNum(cancelledCount) }}
+
+ {{ totalRuns ? Math.round((cancelledCount / totalRuns) * 100) : 0 }}%
@@ -312,6 +334,10 @@
{{ fmtNum(p.failed) }}
+ · 取消
+
+ {{ fmtNum(p.cancelled) }}
+
diff --git a/desktop/controlplane-next/server/src/modules/center/controller/admin/ops.ts b/desktop/controlplane-next/server/src/modules/center/controller/admin/ops.ts
index 860067f..bb147eb 100644
--- a/desktop/controlplane-next/server/src/modules/center/controller/admin/ops.ts
+++ b/desktop/controlplane-next/server/src/modules/center/controller/admin/ops.ts
@@ -105,16 +105,21 @@ export class AdminOpsController extends BaseController {
(SELECT COUNT(*) FROM plugins WHERE status='revoked') AS revoked`))[0];
const runs: any = (await m.query(
`SELECT (SELECT COUNT(*) FROM runtime_reports WHERE status='start') AS started,
+ (SELECT COUNT(*) FROM runtime_reports WHERE status <> 'start') AS finished,
(SELECT COUNT(*) FROM runtime_reports WHERE status IN ('done','success')) AS success,
- (SELECT COUNT(*) FROM runtime_reports WHERE status IN ('error','failed')) AS failed,
+ (SELECT COUNT(*) FROM runtime_reports
+ WHERE status IN ('error','failed','running')) AS failed,
+ (SELECT COUNT(*) FROM runtime_reports WHERE status IN ('cancel','cancelled','canceled')) AS cancelled,
(SELECT COALESCE(SUM(duration_sec),0) FROM runtime_reports) AS duration_sec,
(SELECT COUNT(DISTINCT account) FROM runtime_reports WHERE account <> '') AS active_users,
(SELECT COUNT(DISTINCT plugin_id) FROM runtime_reports WHERE plugin_id <> '') AS active_plugins`))[0];
+ // 取消(用户强制停止 / 排队取消 / 排队超时 / 客户端退出)也落终态,必须计入构成,否则 总数 ≠ 成功+失败
const trendRows: any[] = await m.query(
`SELECT LEFT(at,10) AS day,
SUM(CASE WHEN status='start' THEN 1 ELSE 0 END) AS runs,
SUM(CASE WHEN status IN ('done','success') THEN 1 ELSE 0 END) AS success,
- SUM(CASE WHEN status IN ('error','failed') THEN 1 ELSE 0 END) AS failed
+ SUM(CASE WHEN status IN ('error','failed','running') THEN 1 ELSE 0 END) AS failed,
+ SUM(CASE WHEN status IN ('cancel','cancelled','canceled') THEN 1 ELSE 0 END) AS cancelled
FROM runtime_reports WHERE at >= CURDATE() - INTERVAL 13 DAY GROUP BY day ORDER BY day`);
const trendMap: Record = {};
for (const r of trendRows) trendMap[r.day] = r;
@@ -124,13 +129,20 @@ export class AdminOpsController extends BaseController {
const day = new Date(d.getTime() - i * 86400000);
const key = `${day.getFullYear()}-${String(day.getMonth() + 1).padStart(2, '0')}-${String(day.getDate()).padStart(2, '0')}`;
const r = trendMap[key];
- trend.push({ day: key.slice(5), runs: Number(r?.runs || 0), success: Number(r?.success || 0), failed: Number(r?.failed || 0) });
+ trend.push({
+ day: key.slice(5),
+ runs: Number(r?.runs || 0),
+ success: Number(r?.success || 0),
+ failed: Number(r?.failed || 0),
+ cancelled: Number(r?.cancelled || 0),
+ });
}
const topPlugins: any[] = await m.query(
`SELECT plugin_id AS pluginId, COUNT(*) AS runs,
SUM(CASE WHEN status='start' THEN 1 ELSE 0 END) AS triggered,
SUM(CASE WHEN status IN ('done','success') THEN 1 ELSE 0 END) AS success,
SUM(CASE WHEN status IN ('error','failed') THEN 1 ELSE 0 END) AS failed,
+ SUM(CASE WHEN status IN ('cancel','cancelled','canceled') THEN 1 ELSE 0 END) AS cancelled,
COALESCE(SUM(duration_sec),0) AS durationSec
FROM runtime_reports GROUP BY plugin_id ORDER BY triggered DESC LIMIT 8`);
const pnames: Record = {};
@@ -143,9 +155,26 @@ export class AdminOpsController extends BaseController {
return {
users: { total: Number(users.total || 0), admins: Number(users.admins || 0), authorized: Number(users.authorized || 0) },
plugins: { total: Number(plugins.total || 0), published: Number(plugins.published || 0), testing: Number(plugins.testing || 0), disabled: Number(plugins.disabled || 0), revoked: Number(plugins.revoked || 0) },
- runs: { total: Number(runs.started || 0), success: Number(runs.success || 0), failed: Number(runs.failed || 0), durationSec: Number(runs.duration_sec || 0), activeUsers: Number(runs.active_users || 0), activePlugins: Number(runs.active_plugins || 0) },
+ runs: {
+ // total = 终态记录数(成功+失败+取消),保证三者相加严格等于总数;triggered = 开始上报数(含正在跑/排队取消没开始的)
+ total: Number(runs.finished || 0),
+ triggered: Number(runs.started || 0),
+ success: Number(runs.success || 0),
+ failed: Number(runs.failed || 0),
+ cancelled: Number(runs.cancelled || 0),
+ durationSec: Number(runs.duration_sec || 0),
+ activeUsers: Number(runs.active_users || 0),
+ activePlugins: Number(runs.active_plugins || 0),
+ },
trend,
- topPlugins: topPlugins.map((tp: any) => ({ ...tp, name: pnames[tp.pluginId] || tp.pluginId, runs: Number(tp.triggered || 0) })),
+ topPlugins: topPlugins.map((tp: any) => ({
+ ...tp,
+ name: pnames[tp.pluginId] || tp.pluginId,
+ runs: Number(tp.triggered || 0),
+ success: Number(tp.success || 0),
+ failed: Number(tp.failed || 0),
+ cancelled: Number(tp.cancelled || 0),
+ })),
topUsers: topUsers.map((tu: any) => ({ account: tu.account, runs: Number(tu.runs || 0), nickname: nick[tu.account] || '' })),
today: d.toISOString().slice(0, 10),
};