(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts)
| 227 | } |
| 228 | |
| 229 | func (r *WorkflowRepo) Update(ctx context.Context, id uuid.UUID, opts *biz.WorkflowUpdateOpts) (*biz.Workflow, error) { |
| 230 | ctx, span := otelx.Start(ctx, workflowRepoTracer, "WorkflowRepo.Update") |
| 231 | defer span.End() |
| 232 | |
| 233 | if opts == nil { |
| 234 | opts = &biz.WorkflowUpdateOpts{} |
| 235 | } |
| 236 | |
| 237 | req := r.data.DB.Workflow.UpdateOneID(id). |
| 238 | SetNillableTeam(opts.Team). |
| 239 | SetNillablePublic(opts.Public). |
| 240 | SetNillableDescription(opts.Description). |
| 241 | SetUpdatedAt(time.Now()) |
| 242 | |
| 243 | // Update the contract if provided |
| 244 | if opts.ContractID != nil { |
| 245 | contractUUID, err := uuid.Parse(*opts.ContractID) |
| 246 | if err != nil { |
| 247 | return nil, err |
| 248 | } |
| 249 | req = req.SetContractID(contractUUID) |
| 250 | } |
| 251 | |
| 252 | wf, err := req.Save(ctx) |
| 253 | |
| 254 | if err != nil { |
| 255 | if ent.IsConstraintError(err) { |
| 256 | return nil, biz.NewErrAlreadyExists(err) |
| 257 | } |
| 258 | |
| 259 | return nil, fmt.Errorf("failed to update workflow: %w", err) |
| 260 | } |
| 261 | |
| 262 | // Reload the object to include the relations |
| 263 | return r.FindByID(ctx, wf.ID) |
| 264 | } |
| 265 | |
| 266 | func (r *WorkflowRepo) List(ctx context.Context, orgID uuid.UUID, filter *biz.WorkflowListOpts, pagination *pagination.OffsetPaginationOpts) ([]*biz.Workflow, int, error) { |
| 267 | ctx, span := otelx.Start(ctx, workflowRepoTracer, "WorkflowRepo.List") |
nothing calls this directly
no test coverage detected