Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Create activeTaskInStage to prepare multi-task in stage support

天舟bf24465fc120
diff --git a/frontend/src/utils/pipeline.ts b/frontend/src/utils/pipeline.ts
index 3fa80b9039..ddfead7dc9 100644
--- a/frontend/src/utils/pipeline.ts
+++ b/frontend/src/utils/pipeline.ts
@@ -4,13 +4,13 @@ import {
EMPTY_ID,
Environment,
Pipeline,
+ PipelineCreate,
+ Stage,
Task,
+ TaskId,
TaskStatus,
- Stage,
- UNKNOWN_ID,
unknown,
- TaskId,
- PipelineCreate,
+ UNKNOWN_ID,
} from "../types";
export type PipelineType =
@@ -116,6 +116,27 @@ export function activeTask(pipeline: Pipeline): Task {
return empty("TASK") as Task;
}
+export function activeTaskInStage(stage: Stage): Task {
+ for (const task of stage.taskList) {
+ if (
+ task.status == "PENDING" ||
+ task.status == "PENDING_APPROVAL" ||
+ task.status == "RUNNING" ||
+ // "FAILED" is also a transient task status, which requires user
+ // to take further action (e.g. Skip, Retry)
+ task.status == "FAILED"
+ ) {
+ return task;
+ }
+ }
+
+ if (stage.taskList.length > 0) {
+ return stage.taskList[stage.taskList.length - 1];
+ }
+
+ return empty("TASK") as Task;
+}
+
export function activeEnvironment(pipeline: Pipeline): Environment {
const stage: Stage = activeStage(pipeline);
if (stage.id == EMPTY_ID) {