public void VSOWorkItem_GetVSOWorkItemBuildModel_Test() { var start = DateTime.Parse("2017-09-01"); var end = DateTime.Parse("2017-10-01"); var vso = this.config[SolutionConfigName.VSO_NAME].ToString(); var token = this.config[SolutionConfigName.PERSONAL_ACCESS_TOKEN].ToString(); var areapath = this.config[SolutionConfigName.INCIDENT_VSO_AREA_PATH].ToString(); var buildModelList = WorkItemUtil.GetVSOWorkItemDBModel(vso, start, end, token, areapath); Assert.IsTrue(buildModelList.Count == 0); }
public override void CollectWorkItem(string vso, string project, string areaPath, DateTime start, DateTime end, string token) { var workItemErrorList = WorkItemUtil.GetVSOWorkItemDBModel(vso, start, end, token, areaPath); var metricList = new List <Metric>(); foreach (var item in workItemErrorList) { var detail = item.fields; detail["VSO"] = vso; detail["Project"] = project; detail["Id"] = item.Id; var metric = new Metric("VSO WorkItem", MetricType.VsoWorkItem, detail); metricList.Add(metric); } writer.Write(metricList); }
public static void CreateUserStoryCumulativeData(Connect connect, DumpDataSet ds, int areaId) { List <int> workItemClosed = new List <int>(); var workItemRevisions = WorkItemUtil.GetWorkItemRevisions(ds.WorkItemRevision); if (StaticUtil.CurrentFuzzFile.MaxStateIndex > 15) { throw new Exception("UserStoryCumulativeFlow.CreateUserStoryCumulativeData cannot support more than 15 states."); } DateTime currentWeekEnding = FirstFriday(ds.WorkItem); while (currentWeekEnding <= LastFriday()) { DateTime searchDate = new DateTime(currentWeekEnding.Year, currentWeekEnding.Month, currentWeekEnding.Day, 23, 59, 59); DateTime searchBeginning = searchDate.AddDays(-7); foreach (var workItem in Enumerable.Where(ds.WorkItem, x => x.CreatedDate <= searchDate)) { if (workItem.Type != "User Story" && workItem.Type != "Bug") { continue; } //all revisions up to searchDate var revisions = workItemRevisions.Where(x => x.ID == workItem.ID && x.ChangedDate <= searchDate).OrderBy(y => y.Rev).ToList(); if (!revisions.Any()) { continue; } DumpDataSet.UserStoryFlowRow row = ds.UserStoryFlow.NewUserStoryFlowRow(); row.ID = workItem.ID; row.Title = workItem.Title; row.Type = workItem.Type; row.WeekEndingState = StaticUtil.CurrentFuzzFile.GetCurrentWorkItemState(revisions.Last()).CategoryIndex; if (workItem.CreatedDate <= searchDate && workItem.CreatedDate >= searchBeginning) { row.NewThisWeek = 1; } for (int i = StaticUtil.CurrentFuzzFile.MinStateIndex; i <= StaticUtil.CurrentFuzzFile.MaxStateIndex; i++) { row[string.Format("State{0}Desc", i)] = StaticUtil.CurrentFuzzFile.GetStates(i).First().Category; if (StaticUtil.CurrentFuzzFile.WasInState(revisions, i, searchBeginning, searchDate)) { row[string.Format("State{0}", i)] = 1; } else { row[string.Format("State{0}", i)] = 0; } if (StaticUtil.CurrentFuzzFile.EnteredState(revisions, i, searchBeginning, searchDate)) { row[string.Format("State{0}Entered", i)] = 1; } else { row[string.Format("State{0}Entered", i)] = 0; } } row.WeekEnding = currentWeekEnding; if (row.IsNewThisWeekNull()) { row.NewThisWeek = 0; } if (!row.IsState2Null() && row.State2 == 1) { row.ActiveThisWeek = 1; } if (!row.IsState4Null() && row.State4 == 1) { row.ActiveThisWeek = 1; } if (row.IsActiveThisWeekNull()) { row.ActiveThisWeek = 0; } //closed logic should be: state was <=4 before this week, and >=5 by the end of this week bool wasInClosedDuringThisWeek = row.WeekEndingState >= 5; bool wasClosedBeforeThisWeek = false; var latestRevFromLastWeek = revisions.Where(x => x.ChangedDate < searchBeginning) .OrderBy(x => x.Rev).LastOrDefault(); if (latestRevFromLastWeek != null) { if (latestRevFromLastWeek.LifecycleState >= 5) { wasClosedBeforeThisWeek = true; } } row.Closed = (wasInClosedDuringThisWeek || wasClosedBeforeThisWeek) ? 1 : 0; if (!wasClosedBeforeThisWeek && wasInClosedDuringThisWeek) { row.ClosedThisWeek = 1; } else { row.ClosedThisWeek = 0; } ds.UserStoryFlow.AddUserStoryFlowRow(row); } currentWeekEnding = currentWeekEnding.AddDays(7); } }