public async Task <IActionResult> GetLatest( string repository, string commit, string buildNumber, int?channelId, DateTimeOffset?notBefore, DateTimeOffset?notAfter, bool?loadCollections) { IQueryable <Build> query = Query( repository, commit, buildNumber, channelId, notBefore, notAfter, loadCollections); Build build = await query.OrderByDescending(o => o.DateProduced).FirstOrDefaultAsync(); if (build == null) { return(NotFound()); } return(Ok(new Models.Build(build))); }
private Build ToClientModelBuild(Maestro.Data.Models.Build other) { return(new Build(other.Id, other.DateProduced, other.Staleness, other.PublishUsingPipelines, other.Commit, null, other.Assets?.Select(a => ToClientModelAsset(a)).ToImmutableList(), null) { AzureDevOpsBranch = other.AzureDevOpsBranch, GitHubBranch = other.GitHubBranch, GitHubRepository = other.GitHubRepository, AzureDevOpsRepository = other.AzureDevOpsRepository, }); }
private Build ToClientModelBuild(Maestro.Data.Models.Build other) { return(new Build(other.Id, other.DateProduced, other.Staleness, false, true, other.Commit, null, other.Assets?.Select(a => ToClientModelAsset(a)).ToImmutableList(), other.DependentBuildIds?.Select(b => new BuildRef(b.BuildId, b.IsProduct, b.TimeToInclusionInMinutes)).ToImmutableList()) { AzureDevOpsBranch = other.AzureDevOpsBranch, GitHubBranch = other.GitHubBranch, GitHubRepository = other.GitHubRepository, AzureDevOpsRepository = other.AzureDevOpsRepository, }); }
/// <summary> /// Get a list of builds for the given repo uri and commit. /// </summary> /// <param name="repoUri">Repository uri</param> /// <param name="commit">Commit</param> /// <returns>Build with specific Id</returns> /// <remarks>This only implements the narrow needs of the dependency graph /// builder in context of coherency. For example channels are not included./remarks> public async Task <Build> GetBuildAsync(int buildId) { Maestro.Data.Models.Build build = await _context.Builds.Where(b => b.Id == buildId) .Include(b => b.Assets) .FirstOrDefaultAsync(); if (build == null) { throw new DarcException($"Could not find a build with id '{buildId}'"); } return(ToClientModelBuild(build)); }
public async Task <IActionResult> GetBuild(int id) { Build build = await _context.Builds.Where(b => b.Id == id) .Include(b => b.BuildChannels) .ThenInclude(bc => bc.Channel) .Include(b => b.Assets) .Include(b => b.Dependencies) .FirstOrDefaultAsync(); if (build == null) { return(NotFound()); } return(Ok(new Models.Build(build))); }
public async Task <IActionResult> Create([FromBody] BuildData build) { Build buildModel = build.ToDb(); buildModel.DateProduced = DateTimeOffset.UtcNow; buildModel.Dependencies = build.Dependencies != null ? await _context.Builds.Where(b => build.Dependencies.Contains(b.Id)).ToListAsync() : null; await _context.Builds.AddAsync(buildModel); await _context.SaveChangesAsync(); return(CreatedAtRoute( new { action = "GetBuild", id = buildModel.Id }, new Models.Build(buildModel))); }