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: apply sampling size (#15932)
Danny Xuae37a4ef1aee
diff --git a/backend/api/v1/plan_service_plan_check.go b/backend/api/v1/plan_service_plan_check.goindex a345163ef4..0c013202ee 100644--- a/backend/api/v1/plan_service_plan_check.go+++ b/backend/api/v1/plan_service_plan_check.go@@ -2,6 +2,7 @@ package v1import ("context"+ "fmt""github.com/pkg/errors"@@ -51,6 +52,19 @@ func getPlanCheckRunsFromPlanSpecs(ctx context.Context, s *store.Store, plan *stplanCheckRuns = append(planCheckRuns, runs...)}}+ if project.Setting.GetCiSamplingSize() > 0 {+ var updatedRuns []*store.PlanCheckRunMessage+ countMap := make(map[string]int32)+ for _, run := range planCheckRuns {+ key := fmt.Sprintf("%s/%s/%s/%d", run.Type, run.Config.GetInstanceId(), run.Config.GetDatabaseName(), run.Config.GetSheetUid())+ if countMap[key] >= project.Setting.GetCiSamplingSize() {+ continue+ }+ updatedRuns = append(updatedRuns, run)+ countMap[key]+++ }+ planCheckRuns = updatedRuns+ }return planCheckRuns, nil}