| 1 | using AgentForge.Data.Entities; |
| 2 | using AgentForge.Plugin.Ci.Contracts; |
| 3 | |
| 4 | namespace AgentForge.Plugin.Ci.Data; |
| 5 | |
| 6 | internal sealed record CiRunScope( |
| 7 | ForgeRepoEntity Repo, |
| 8 | ForgeCiPipelineRunRecord Run, |
| 9 | ForgeCiRunStore Runs); |
| 10 | |
| 11 | internal static class ForgeCiRunResolve |
| 12 | { |
| 13 | internal static CiRunScope? TryGetRunScope( |
| 14 | ForgeRepoEntity repo, |
| 15 | ForgeCiRunStore runs, |
| 16 | string runId) |
| 17 | { |
| 18 | var run = runs.GetRun(repo.Id, runId); |
| 19 | return run is null ? null : new CiRunScope(repo, run, runs); |
| 20 | } |
| 21 | |
| 22 | internal static ForgeCiStepRunRecord? TryGetStep(CiRunScope scope, string stepId) => |
| 23 | scope.Runs.ListSteps(scope.Run.Id).FirstOrDefault(s => s.Id == stepId); |
| 24 | |
| 25 | internal static IReadOnlyList<CiRunSummaryResponse> ListSummaries( |
| 26 | ForgeRepoEntity repo, |
| 27 | ForgeCiRunStore runs) => |
| 28 | runs.ListRuns(repo.Id) |
| 29 | .Select(r => new CiRunSummaryResponse( |
| 30 | r.Id, |
| 31 | repo.Name, |
| 32 | r.DefinitionName, |
| 33 | r.Ref, |
| 34 | r.Status, |
| 35 | r.CreatedAt, |
| 36 | r.UpdatedAt)) |
| 37 | .ToList(); |
| 38 | } |
| 39 | |
View only · write via MCP/CIDE