entWrPolicySummary builds the domain summary from the materialized columns. Returns nil when the row predates the materialization change (all columns NULL) so callers can tell "never computed" apart from "computed and empty".
(wr *ent.WorkflowRun)
| 619 | // Returns nil when the row predates the materialization change (all columns |
| 620 | // NULL) so callers can tell "never computed" apart from "computed and empty". |
| 621 | func entWrPolicySummary(wr *ent.WorkflowRun) *chainloop.PolicyStatusSummary { |
| 622 | if wr.PolicyStatus == nil { |
| 623 | return nil |
| 624 | } |
| 625 | |
| 626 | s := &chainloop.PolicyStatusSummary{ |
| 627 | Status: entToPolicyStatus(*wr.PolicyStatus), |
| 628 | } |
| 629 | if wr.PolicyEvaluationsTotal != nil { |
| 630 | s.Total = int(*wr.PolicyEvaluationsTotal) |
| 631 | } |
| 632 | if wr.PolicyEvaluationsPassed != nil { |
| 633 | s.Passed = int(*wr.PolicyEvaluationsPassed) |
| 634 | } |
| 635 | if wr.PolicyEvaluationsSkipped != nil { |
| 636 | s.Skipped = int(*wr.PolicyEvaluationsSkipped) |
| 637 | } |
| 638 | if wr.PolicyViolationsCount != nil { |
| 639 | s.Violated = int(*wr.PolicyViolationsCount) |
| 640 | } |
| 641 | if wr.PolicyViolationsSuppressed != nil { |
| 642 | s.Suppressed = int(*wr.PolicyViolationsSuppressed) |
| 643 | } |
| 644 | if wr.PolicyHasGates != nil { |
| 645 | s.HasGates = *wr.PolicyHasGates |
| 646 | } |
| 647 | return s |
| 648 | } |
no test coverage detected