GetSQLReviewResult will wait for next task SQL review task check to finish and return the task check result.
(ctx context.Context, plan *v1pb.Plan)
| 30 | |
| 31 | // GetSQLReviewResult will wait for next task SQL review task check to finish and return the task check result. |
| 32 | func (ctl *controller) GetSQLReviewResult(ctx context.Context, plan *v1pb.Plan) (*v1pb.PlanCheckRun, error) { |
| 33 | ticker := time.NewTicker(100 * time.Millisecond) |
| 34 | defer ticker.Stop() |
| 35 | |
| 36 | for range ticker.C { |
| 37 | resp, err := ctl.planServiceClient.GetPlanCheckRun(ctx, connect.NewRequest(&v1pb.GetPlanCheckRunRequest{ |
| 38 | Name: fmt.Sprintf("%s/planCheckRun", plan.Name), |
| 39 | })) |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | check := resp.Msg |
| 44 | hasStatementAdvise := false |
| 45 | for _, result := range check.Results { |
| 46 | if result.Type == v1pb.PlanCheckRun_Result_STATEMENT_ADVISE { |
| 47 | hasStatementAdvise = true |
| 48 | break |
| 49 | } |
| 50 | } |
| 51 | if hasStatementAdvise { |
| 52 | if check.Status == v1pb.PlanCheckRun_DONE || check.Status == v1pb.PlanCheckRun_FAILED { |
| 53 | return check, nil |
| 54 | } |
| 55 | } |
| 56 | } |
| 57 | return nil, nil |
| 58 | } |
| 59 | |
| 60 | // getSchemaDiff gets the schema diff. |
| 61 | func (ctl *controller) getSchemaDiff(ctx context.Context, schemaDiff *v1pb.DiffSchemaRequest) (string, error) { |