Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: show running status for plan check runs (#17046)
boojack87932afd3dd5
diff --git a/backend/api/v1/rollout_service_converter.go b/backend/api/v1/rollout_service_converter.goindex 3560ab84cb..6f0da141db 100644--- a/backend/api/v1/rollout_service_converter.go+++ b/backend/api/v1/rollout_service_converter.go@@ -37,8 +37,8 @@ func convertToPlan(ctx context.Context, s *store.Store, plan *store.PlanMessage)Deployment: convertToPlanDeployment(plan.Config.Deployment),CreateTime: timestamppb.New(plan.CreatedAt),UpdateTime: timestamppb.New(plan.UpdatedAt),- PlanCheckRunStatusCount: plan.PlanCheckRunStatusCount,State: convertDeletedToState(plan.Deleted),+ PlanCheckRunStatusCount: map[string]int32{},}creator, err := s.GetUserByID(ctx, plan.CreatorUID)@@ -57,6 +57,18 @@ func convertToPlan(ctx context.Context, s *store.Store, plan *store.PlanMessage)if plan.PipelineUID != nil {p.Rollout = common.FormatRollout(plan.ProjectID, *plan.PipelineUID)}+ planCheckRuns, err := s.ListPlanCheckRuns(ctx, &store.FindPlanCheckRunMessage{+ PlanUID: &plan.UID,+ })+ if err != nil {+ return nil, errors.Wrapf(err, "failed to list plan check runs for plan uid %d", plan.UID)+ }+ for _, run := range planCheckRuns {+ p.PlanCheckRunStatusCount[string(run.Status)]+++ for _, result := range run.Result.Results {+ p.PlanCheckRunStatusCount[storepb.PlanCheckRunResult_Result_Status_name[int32(result.Status)]]+++ }+ }return p, nil}diff --git a/backend/generated-go/v1/plan_service.pb.go b/backend/generated-go/v1/plan_service.pb.goindex 42dd97d277..1c72258bc6 100644--- a/backend/generated-go/v1/plan_service.pb.go+++ b/backend/generated-go/v1/plan_service.pb.go@@ -716,6 +716,7 @@ type Plan struct {// - SUCCESS// - WARNING// - ERROR+ // - RUNNINGPlanCheckRunStatusCount map[string]int32 `protobuf:"bytes,11,rep,name=plan_check_run_status_count,json=planCheckRunStatusCount,proto3" json:"plan_check_run_status_count,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"varint,2,opt,name=value"`Deployment *Plan_Deployment `protobuf:"bytes,13,opt,name=deployment,proto3" json:"deployment,omitempty"`unknownFields protoimpl.UnknownFieldsdiff --git a/backend/store/plan.go b/backend/store/plan.goindex f578013617..4120802d5f 100644--- a/backend/store/plan.go+++ b/backend/store/plan.go@@ -3,7 +3,6 @@ package storeimport ("context""database/sql"- "encoding/json""fmt""strings""time"@@ -28,8 +27,6 @@ type PlanMessage struct {CreatedAt time.TimeUpdatedAt time.TimeDeleted bool-- PlanCheckRunStatusCount map[string]int32}// FindPlanMessage is the message to find a plan.@@ -157,27 +154,9 @@ func (s *Store) ListPlans(ctx context.Context, find *FindPlanMessage) ([]*PlanMeplan.name,plan.description,plan.config,- plan.deleted,- COALESCE(plan_check_run_status_count.status_count, '{}'::jsonb)+ plan.deletedFROM planLEFT JOIN issue on plan.id = issue.plan_id- LEFT JOIN LATERAL (- SELECT- jsonb_object_agg(a.status, a.count) AS status_count- FROM (- SELECT- e->>'status' AS status,- COUNT(*) AS count- FROM (- SELECT DISTINCT ON (plan_check_run.type, plan_check_run.config->>'instanceId', plan_check_run.config->>'databaseName', plan_check_run.config->>'sheetUid')- jsonb_array_elements(plan_check_run.result->'results') e- FROM plan_check_run- WHERE plan_check_run.plan_id = plan.id- ORDER BY plan_check_run.type, plan_check_run.config->>'instanceId', plan_check_run.config->>'databaseName', plan_check_run.config->>'sheetUid', plan_check_run.id DESC- ) r- GROUP BY e->>'status'- ) a- ) plan_check_run_status_count ON TRUEWHERE %sORDER BY id DESC`, strings.Join(where, " AND "))@@ -205,7 +184,7 @@ func (s *Store) ListPlans(ctx context.Context, find *FindPlanMessage) ([]*PlanMeplan := PlanMessage{Config: &storepb.PlanConfig{},}- var config, statusCount []byte+ var config []byteif err := rows.Scan(&plan.UID,&plan.CreatorUID,@@ -217,16 +196,12 @@ func (s *Store) ListPlans(ctx context.Context, find *FindPlanMessage) ([]*PlanMe&plan.Description,&config,&plan.Deleted,- &statusCount,); err != nil {return nil, errors.Wrap(err, "failed to scan plan")}if err := common.ProtojsonUnmarshaler.Unmarshal(config, plan.Config); err != nil {return nil, errors.Wrap(err, "failed to unmarshal plan config")}- if err := json.Unmarshal(statusCount, &plan.PlanCheckRunStatusCount); err != nil {- return nil, errors.Wrapf(err, "failed to unmarshal plan check run status count")- }plans = append(plans, &plan)}if err := rows.Err(); err != nil {diff --git a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vueindex 7f1e0fe35b..8f4f8e2b05 100644--- a/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue+++ b/frontend/src/components/Plan/components/PlanCheckSection/PlanCheckSection.vue@@ -25,34 +25,64 @@<div class="flex items-center gap-2"><!-- Status Summary --><div class="flex items-center gap-2 text-sm">+ <div+ v-if="+ getChecksCount(PlanCheckRun_Status[PlanCheckRun_Status.RUNNING]) >+ 0+ "+ class="flex items-center gap-1"+ >+ <LoaderIcon class="w-5 h-5 text-control animate-spin" />+ <span class="text-control">{{+ getChecksCount(PlanCheckRun_Status[PlanCheckRun_Status.RUNNING])+ }}</span>+ </div><button- v-if="getChecksCount(PlanCheckRun_Result_Status.ERROR) > 0"+ v-if="+ getChecksCount(+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]+ ) > 0+ "class="flex items-center gap-1 hover:opacity-80"@click="openChecksDrawer(PlanCheckRun_Result_Status.ERROR)"><XCircleIcon class="w-5 h-5 text-error" /><span class="text-error">{{- getChecksCount(PlanCheckRun_Result_Status.ERROR)+ getChecksCount(+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.ERROR]+ )}}</span></button><button- v-if="getChecksCount(PlanCheckRun_Result_Status.WARNING) > 0"+ v-if="+ getChecksCount(+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]+ ) > 0+ "class="flex items-center gap-1 hover:opacity-80"@click="openChecksDrawer(PlanCheckRun_Result_Status.WARNING)"><AlertCircleIcon class="w-5 h-5 text-warning" /><span class="text-warning">{{- getChecksCount(PlanCheckRun_Result_Status.WARNING)+ getChecksCount(+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.WARNING]+ )}}</span></button><button- v-if="getChecksCount(PlanCheckRun_Result_Status.SUCCESS) > 0"+ v-if="+ getChecksCount(+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]+ ) > 0+ "class="flex items-center gap-1 hover:opacity-80"@click="openChecksDrawer(PlanCheckRun_Result_Status.SUCCESS)"><CheckCircleIcon class="w-5 h-5 text-success" /><span class="text-success">{{- getChecksCount(PlanCheckRun_Result_Status.SUCCESS)+ getChecksCount(+ PlanCheckRun_Result_Status[PlanCheckRun_Result_Status.SUCCESS]+ )}}</span></button></div>@@ -87,6 +117,7 @@ import {AlertCircleIcon,XCircleIcon,PlayIcon,+ LoaderIcon,} from "lucide-vue-next";import { NButton, NTooltip, NTag } from "naive-ui";import { computed, ref, watch } from "vue";@@ -99,6 +130,7 @@ import {} from "@/store";import {PlanCheckRun_Result_Status,+ PlanCheckRun_Status,RunPlanChecksRequestSchema,} from "@/types/proto-es/v1/plan_service_pb";import { hasProjectPermissionV2 } from "@/utils";@@ -155,10 +187,8 @@ const affectedRows = computed(() => {}, 0);});-const getChecksCount = (status: PlanCheckRun_Result_Status) => {- return (- plan.value.planCheckRunStatusCount[PlanCheckRun_Result_Status[status]] || 0- );+const getChecksCount = (status: string) => {+ return plan.value.planCheckRunStatusCount[status] || 0;};const runChecks = async () => {diff --git a/frontend/src/components/Plan/logic/poller/poller.ts b/frontend/src/components/Plan/logic/poller/poller.tsindex 3b1b1f4608..7b17c9d0da 100644--- a/frontend/src/components/Plan/logic/poller/poller.ts+++ b/frontend/src/components/Plan/logic/poller/poller.ts@@ -192,6 +192,11 @@ export const provideResourcePoller = () => {} finally {isRefreshing.value = false;}++ // If force is true, restart the poller to ensure it continues polling.+ if (force) {+ resourcePoller.restart();+ }};// Create a single poller for all resourcesdiff --git a/frontend/src/store/modules/v1/plan.ts b/frontend/src/store/modules/v1/plan.tsindex 50a55c1936..b63b570ff8 100644--- a/frontend/src/store/modules/v1/plan.ts+++ b/frontend/src/store/modules/v1/plan.ts@@ -100,13 +100,13 @@ export const usePlanStore = defineStore("plan", () => {pageSize,pageToken,});- const resp = await planServiceClientConnect.searchPlans(request);- const plans = resp.plans;+ const { plans, nextPageToken } =+ await planServiceClientConnect.searchPlans(request);// Prepare creator for the plans.const users = uniq(plans.map((plan) => plan.creator));await useUserStore().batchGetUsers(users);return {- nextPageToken: resp.nextPageToken,+ nextPageToken: nextPageToken,plans,};};diff --git a/frontend/src/types/proto-es/v1/plan_service_pb.d.ts b/frontend/src/types/proto-es/v1/plan_service_pb.d.tsindex 2859238de1..c51553c646 100644--- a/frontend/src/types/proto-es/v1/plan_service_pb.d.ts+++ b/frontend/src/types/proto-es/v1/plan_service_pb.d.ts@@ -321,6 +321,7 @@ export declare type Plan = Message<"bytebase.v1.Plan"> & {* - SUCCESS* - WARNING* - ERROR+ * - RUNNING** @generated from field: map<string, int32> plan_check_run_status_count = 11;*/diff --git a/proto/gen/grpc-doc/openapi.yaml b/proto/gen/grpc-doc/openapi.yamlindex b98fc9d7c5..2a1798a4ed 100644--- a/proto/gen/grpc-doc/openapi.yaml+++ b/proto/gen/grpc-doc/openapi.yaml@@ -11547,6 +11547,7 @@ components:- SUCCESS- WARNING- ERROR+ - RUNNINGdeployment:$ref: '#/components/schemas/Plan_Deployment'PlanCheckRun:diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.mdindex 1f2775a30f..4f65b938cb 100644--- a/proto/gen/grpc-doc/v1/README.md+++ b/proto/gen/grpc-doc/v1/README.md@@ -7269,7 +7269,7 @@ When paginating, all other parameters provided to `ListPlans` must match the cal| creator | [string](#string) | | Format: users/[email protected] || create_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | || update_time | [google.protobuf.Timestamp](#google-protobuf-Timestamp) | | |-| plan_check_run_status_count | [Plan.PlanCheckRunStatusCountEntry](#bytebase-v1-Plan-PlanCheckRunStatusCountEntry) | repeated | The status count of the latest plan check runs. Keys are: - SUCCESS - WARNING - ERROR |+| plan_check_run_status_count | [Plan.PlanCheckRunStatusCountEntry](#bytebase-v1-Plan-PlanCheckRunStatusCountEntry) | repeated | The status count of the latest plan check runs. Keys are: - SUCCESS - WARNING - ERROR - RUNNING || deployment | [Plan.Deployment](#bytebase-v1-Plan-Deployment) | | |diff --git a/proto/gen/grpc-doc/v1/index.html b/proto/gen/grpc-doc/v1/index.htmlindex 0cb224dc24..6e9f1facf6 100644--- a/proto/gen/grpc-doc/v1/index.html+++ b/proto/gen/grpc-doc/v1/index.html@@ -20384,7 +20384,8 @@ Format: projects/{project}/rollouts/{rollout} </p></td>Keys are:- SUCCESS- WARNING-- ERROR </p></td>+- ERROR+- RUNNING </p></td></tr><tr>diff --git a/proto/v1/v1/plan_service.proto b/proto/v1/v1/plan_service.protoindex f9b9d43a75..f197ec7fd1 100644--- a/proto/v1/v1/plan_service.proto+++ b/proto/v1/v1/plan_service.proto@@ -266,6 +266,7 @@ message Plan {// - SUCCESS// - WARNING// - ERROR+ // - RUNNINGmap<string, int32> plan_check_run_status_count = 11 [(google.api.field_behavior) = OUTPUT_ONLY];Deployment deployment = 13;