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 JourneyQualityMeasureValue Measure(DatePeriodValue period = null) { var resultAvailability = new List <decimal>(); var resultLatency = new List <decimal>(); var resultExperience = new List <decimal>(); foreach (var map in this.FeatureMap) { QualityMeasureValue measure; if (period != null) { measure = map.Feature.Measure(period); } else { measure = map.Feature.Measure(); } if (measure.HasData) { resultAvailability.Add(measure.Availability); resultLatency.Add(measure.Latency); resultExperience.Add(measure.Experience); } } if (resultAvailability.Count > 0 || resultExperience.Count > 0 || resultLatency.Count > 0) { return(new JourneyQualityMeasureValue( this.AvailabilitySlo, this.LatencySlo, this.ExperienceSlo, QualityUtils.CalculateMinimum(resultAvailability, round: 3), QualityUtils.CalculateMaximum(resultLatency, round: 3), QualityUtils.CalculateMinimum(resultExperience, round: 3))); } else { return(new JourneyQualityMeasureValue(this.AvailabilitySlo, this.LatencySlo, this.ExperienceSlo, false)); } }