コード例 #1
0
        public List <TestFailureData> GetTestFailures([FromUri] DateTimeOffset?startDate = null, [FromUri] string viewName = AzureUtil.ViewNameAll)
        {
            var startDateValue = startDate ?? DateTimeOffset.UtcNow - TimeSpan.FromDays(1);
            var list           = new List <TestFailureData>();

            foreach (var group in _buildUtil.GetTestCaseFailures(startDateValue, viewName).GroupBy(x => x.Identifier))
            {
                var commitFailure = 0;
                var prFailure     = 0;
                foreach (var entity in group)
                {
                    if (JobUtil.IsPullRequestJobName(entity.BuildId.JobName))
                    {
                        prFailure++;
                    }
                    else
                    {
                        commitFailure++;
                    }
                }

                var item = new TestFailureData()
                {
                    Name                = group.Key,
                    TotalFailures       = commitFailure + prFailure,
                    CommitFailures      = commitFailure,
                    PullRequestFailures = prFailure
                };

                list.Add(item);
            }

            return(list);
        }
コード例 #2
0
        public TestFailureData GetTestFailure([FromUri] string name, [FromUri] DateTimeOffset?startDate = null, string viewName = AzureUtil.ViewNameRoslyn)
        {
            var data = new TestFailureData()
            {
                Name   = name,
                Builds = new List <BuildData>()
            };

            var startDateValue = startDate ?? DateTimeOffset.UtcNow - TimeSpan.FromDays(1);
            var prCount        = 0;
            var commitCount    = 0;

            foreach (var entity in _buildUtil.GetTestCaseFailures(startDateValue, name, viewName))
            {
                var buildId = entity.BuildId;
                var jobId   = buildId.JobId;
                if (JobUtil.IsPullRequestJobName(jobId.Name))
                {
                    prCount++;
                }
                else
                {
                    commitCount++;
                }

                var buildData = new BuildData()
                {
                    JobName      = jobId.Name,
                    JobShortName = jobId.ShortName,
                    JobUri       = entity.BoundBuildId.JobUri.ToString(),
                    MachineName  = entity.MachineName,
                    DateTime     = startDateValue,
                };

                data.Builds.Add(buildData);
            }

            data.TotalFailures       = prCount + commitCount;
            data.CommitFailures      = commitCount;
            data.PullRequestFailures = prCount;
            return(data);
        }