public void GenerateDaysMonth() { var target = new DatePeriodValue(new DateTime(2019, 4, 1), new DateTime(2019, 4, 30)); var periods = target.ToDaysPeriods(); Assert.Equal(30, periods.Count); }
public async Task <JourneyGroupListRp> GetJourneyGroupReport(int productId, DatePeriodValue period) { var entity = await this._dbContext.FullLoadProductWithSourceItems(productId, period.Start, period.End); var result = new JourneyGroupListRp(); var days = period.ToDaysPeriods(); foreach (var group in entity.Journeys.GroupBy(c => c.Group)) { var serie = new MultiSerieItemGetRp() { Name = group.Key }; foreach (var day in days) { serie.Items.Add(new SeriesItemGetRp(day.Start, group.Select(c => c.Measure(day).AvailabilityDebt).Sum())); } var measures = group.Select(c => new { measure = c.Measure(period) }).ToList(); var temp = new JourneyGroupListRp.JourneyGrouptem { Name = group.Key, AvailabilitySloAvg = QualityUtils.CalculateAverage(group.Select(c => c.AvailabilitySlo)), AvailabilitySloMin = QualityUtils.CalculateMinimum(group.Select(c => c.AvailabilitySlo)), LatencySloAvg = QualityUtils.CalculateAverage(group.Select(c => c.LatencySlo)), LatencySloMin = QualityUtils.CalculateMinimum(group.Select(c => c.LatencySlo)), ExperienceSloAvg = QualityUtils.CalculateAverage(group.Select(c => c.ExperienceSlo)), ExperienceSloMin = QualityUtils.CalculateMinimum(group.Select(c => c.ExperienceSlo)) }; temp.AvailabilityAvg = QualityUtils.CalculateAverage(measures.Select(c => c.measure.Availability)); temp.AvailabilityMin = QualityUtils.CalculateMinimum(measures.Select(c => c.measure.Availability)); temp.LatencyAvg = QualityUtils.CalculateAverage(measures.Select(c => c.measure.Latency)); temp.LatencyMin = QualityUtils.CalculateMinimum(measures.Select(c => c.measure.Latency)); temp.ExperienceAvg = QualityUtils.CalculateAverage(measures.Select(c => c.measure.Experience)); temp.ExperienceMin = QualityUtils.CalculateMinimum(measures.Select(c => c.measure.Experience)); temp.Count = group.Count(); temp.AvailabilityDebt = measures.Sum(c => c.measure.AvailabilityDebt); temp.ExperienceDebt = measures.Sum(c => c.measure.ExperienceDebt); temp.LatencyDebt = measures.Sum(c => c.measure.LatencyDebt); result.Series.Add(serie); result.Items.Add(temp); } return(result); }
public async Task <DatetimeSerieModel> GetJourneyGroupDailyErrorBudget(int productId, DatePeriodValue period, string group) { var product = await this._dbContext.FullLoadProductWithGroupAndSourceItems(productId, group, period.Start, period.End); var result = new DatetimeSerieModel(); result.Start = period.Start; result.End = period.End; result.Name = product.Name; var days = period.ToDaysPeriods(); foreach (var item in days) { var temp = product.Journeys.Select(c => c.Measure(item)); result.Availability.Items.Add(new DatetimeSerieItemModel(item.Start, temp.Sum(c => c.AvailabilityDebt))); result.Latency.Items.Add(new DatetimeSerieItemModel(item.Start, temp.Sum(c => c.LatencyDebt))); result.Experience.Items.Add(new DatetimeSerieItemModel(item.Start, temp.Sum(c => c.ExperienceDebt))); } foreach (var journey in product.Journeys) { var temp = new DatetimeSerieListModel() { Name = journey.Name, Avatar = journey.Avatar }; temp.AddItems(days.Select(c => (c.Start, journey.Measure(c).AvailabilityDebt)).ToList()); result.AvailabilityDetail.Add(temp); var tempL = new DatetimeSerieListModel() { Name = journey.Name, Avatar = journey.Avatar }; tempL.AddItems(days.Select(c => (c.Start, journey.Measure(c).LatencyDebt)).ToList()); result.LatencyDetail.Add(tempL); var tempE = new DatetimeSerieListModel() { Name = journey.Name, Avatar = journey.Avatar }; tempE.AddItems(days.Select(c => (c.Start, journey.Measure(c).ExperienceDebt)).ToList()); result.ExperienceDetail.Add(tempE); } return(result); }