Exemplo n.º 1
0
        private void FilterReleasesByN(List <string> releaseId, List <string> deploymentId)
        {
            foreach (var releaseItem in Releases.GroupJoin(
                         Deployments,
                         release => release.Id,
                         deployment => deployment.ReleaseId,
                         (x, y) => new { Release = x, Deployments = y })
                     .SelectMany(
                         x => x.Deployments.DefaultIfEmpty(),
                         (x, y) => new { Releases = x.Release, Deployment = y })
                     .OrderByDescending(x => x.Deployment?.DeployedAt)
                     .GroupBy(x => x.Releases.Id)
                     .Take(_releasesToKeep).ToList())
            {
                releaseId.Add(releaseItem.Select(x => x.Releases.Id).FirstOrDefault());

                foreach (var deploymentItem in releaseItem.Select(x => x.Deployment))
                {
                    if (deploymentItem != null)
                    {
                        deploymentId.Add(deploymentItem?.Id);
                    }
                }
            }
        }