(ctx context.Context, w *ent.Workflow)
| 500 | } |
| 501 | |
| 502 | func entWFToBizWF(ctx context.Context, w *ent.Workflow) (*biz.Workflow, error) { |
| 503 | wf := &biz.Workflow{Name: w.Name, ID: w.ID, |
| 504 | CreatedAt: toTimePtr(w.CreatedAt), Team: w.Team, |
| 505 | RunsCounter: w.RunsCount, |
| 506 | Public: w.Public, |
| 507 | Description: w.Description, |
| 508 | OrgID: w.OrganizationID, |
| 509 | ProjectID: w.ProjectID, |
| 510 | WorkflowTemplateID: w.WorkflowTemplateID, |
| 511 | } |
| 512 | |
| 513 | // Set p either pre-loaded or queried |
| 514 | if p := w.Edges.Project; p != nil { |
| 515 | wf.Project = p.Name |
| 516 | wf.ProjectID = p.ID |
| 517 | } |
| 518 | |
| 519 | if contract := w.Edges.Contract; contract != nil { |
| 520 | wf.ContractID = contract.ID |
| 521 | wf.ContractName = contract.Name |
| 522 | lv, err := latestVersion(context.Background(), contract) |
| 523 | if err != nil { |
| 524 | return nil, fmt.Errorf("finding contract version: %w", err) |
| 525 | } |
| 526 | wf.ContractRevisionLatest = lv.Revision |
| 527 | } |
| 528 | |
| 529 | if latestRun := w.Edges.LatestWorkflowRun; latestRun != nil { |
| 530 | lastRun, err := entWrToBizWr(ctx, latestRun) |
| 531 | if err != nil { |
| 532 | return nil, fmt.Errorf("converting workflow run: %w", err) |
| 533 | } |
| 534 | |
| 535 | wf.LastRun = lastRun |
| 536 | } |
| 537 | |
| 538 | return wf, nil |
| 539 | } |
no test coverage detected