private IBuildMetric Calculate(List <Build> builds, BuildFilter buildFilter, IBuildMetric buildMetric)
        {
            var filteredBuilds = new FilterBuilds(builds).Filter(buildFilter);

            var fromDate = GetFromDate(buildFilter.NumberOfWeeks);

            for (var x = 0; x < buildFilter.NumberOfWeeks; x++)
            {
                var startDate = fromDate.AddDays(x * 7);

                buildMetric.SetDate(startDate);

                var buildsForDateRange = new FilterBuilds(filteredBuilds).GetBuildsForOneWeekFrom(startDate);

                foreach (var build in new BuildType().GetDistinctBuildTypes(buildsForDateRange))
                {
                    buildMetric.Add(_build,
                                    new FilterBuilds(buildsForDateRange).GetBuildsFor(
                                        new BuildGroup(build.BuildTypeId)));
                }

                buildMetric.Calculate();
            }

            return(buildMetric);
        }
        public List <BuildStabilityMetric> CalculateBuildStability(BuildFilter buildFilter, IBuildMetric buildMetric)
        {
            var builds = _build.GetBuilds();

            var buildMetrics = (BuildStabilityMetric)Calculate(builds, buildFilter, buildMetric);

            return(buildMetrics
                   .GetResults()
                   .OrderBy(result => result.Date)
                   .ToList());
        }
        public List <BuildDeploymentMetric> CalculateBuildDeployment(BuildFilter buildFilter, IBuildMetric buildMetric)
        {
            var builds = _build.GetSuccessfulBuildStepsContaining("Production");

            var buildMetrics = (BuildDeploymentMetric)Calculate(builds, buildFilter, buildMetric);

            return(buildMetrics
                   .GetResults()
                   .OrderBy(result => result.Date)
                   .ToList());
        }
        public List <BuildThroughputMetric> CalculateBuildThroughput(BuildFilter buildFilter, IBuildMetric buildMetric)
        {
            var builds = _build.GetSuccessfulBuildStepsContaining("_01");

            var buildMetrics = (BuildThroughputMetric)Calculate(builds, buildFilter, buildMetric);

            return(buildMetrics
                   .GetResults()
                   .OrderBy(result => result.Date)
                   .ToList());
        }