Skip to content

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

chore: find plan check run list by target from spec (#7653)

Liu Ji00097b9868bf
diff --git a/frontend/src/components/IssueV1/logic/plan-check.ts b/frontend/src/components/IssueV1/logic/plan-check.ts
index b4862fb1b5..7c35b2ffa3 100644
--- a/frontend/src/components/IssueV1/logic/plan-check.ts
+++ b/frontend/src/components/IssueV1/logic/plan-check.ts
@@ -8,13 +8,16 @@ import {
Task,
Task_Status,
} from "@/types/proto/v1/rollout_service";
-import { databaseForTask } from ".";
+import { databaseForTask, specForTask, targetForSpec } from ".";
export const planCheckRunListForTask = (issue: ComposedIssue, task: Task) => {
- const database = databaseForTask(issue, task);
- return issue.planCheckRunList.filter(
- (check) => check.target === database.name
- );
+ const spec = specForTask(issue.planEntity, task);
+ // If the task's spec is found, use its target.
+ // This is useful when the spec's target is a database group, which means the
+ // planCheckRuns' targets will be the database group rather than the databases.
+ // Otherwise use database for task as the fallback target.
+ const target = targetForSpec(spec) ?? databaseForTask(issue, task).name;
+ return issue.planCheckRunList.filter((check) => check.target === target);
};
export const allPlanChecksPassedForTask = (
diff --git a/frontend/src/components/IssueV1/logic/plan.ts b/frontend/src/components/IssueV1/logic/plan.ts
index 13e7288976..6614fad30f 100644
--- a/frontend/src/components/IssueV1/logic/plan.ts
+++ b/frontend/src/components/IssueV1/logic/plan.ts
@@ -3,3 +3,13 @@ import { Plan_Spec } from "@/types/proto/v1/rollout_service";
export const sheetNameForSpec = (spec: Plan_Spec): string => {
return spec.changeDatabaseConfig?.sheet ?? "";
};
+
+export const targetForSpec = (spec: Plan_Spec | undefined) => {
+ if (!spec) return undefined;
+ return (
+ spec.changeDatabaseConfig?.target ??
+ spec.createDatabaseConfig?.target ??
+ spec.restoreDatabaseConfig?.target ??
+ undefined
+ );
+};