feat: show demo flow progress and elapsed time
This commit is contained in:
@@ -1262,6 +1262,26 @@ export const appRouter = router({
|
||||
.mutation(async ({ input }) => {
|
||||
markDemoFlowCancelled(input.taskId);
|
||||
const result = await cancelTaskAnalysisResultsByTask(input.taskId, "用户停止一键全流程演示");
|
||||
const rows = await db.listTaskAnalysisResults(input.taskId);
|
||||
const latestDemoRow = rows.find((row) => {
|
||||
const data = row.resultData as Record<string, unknown> | null;
|
||||
return typeof data?.demoFlowRunId === "string";
|
||||
});
|
||||
if (latestDemoRow) {
|
||||
const latestDemoData = latestDemoRow.resultData as Record<string, unknown>;
|
||||
const latestRunId = latestDemoData.demoFlowRunId;
|
||||
const cancelledAt = new Date().toISOString();
|
||||
// 即使停止发生在“配准完成、测量记录尚未创建”的短暂窗口,
|
||||
// 也在本次链路的全部现有记录上留下结束标记,避免刷新后重新显示为排队中。
|
||||
await Promise.all(
|
||||
rows
|
||||
.filter((row) => {
|
||||
const data = row.resultData as Record<string, unknown> | null;
|
||||
return data?.demoFlowRunId === latestRunId;
|
||||
})
|
||||
.map((row) => db.patchTaskAnalysisResultData(row.id, { demoFlowCancelledAt: cancelledAt })),
|
||||
);
|
||||
}
|
||||
return {
|
||||
...result,
|
||||
scheduler: algorithmJobStats(),
|
||||
|
||||
Reference in New Issue
Block a user