public async Task <DatetimeSerieModel> GetDailySeriesById(int journeyId, DatePeriodValue period) { var journey = await this._dbContext.GetJourney(journeyId); var sourceIds = journey.FeatureMap.SelectMany(c => c.Feature.Indicators) .Select(c => c.SourceId).Distinct(); var sourceItems = await this._dbContext.GetSourceItems(sourceIds, period.Start, period.End); foreach (var map in journey.FeatureMap) { foreach (var indicator in map.Feature.Indicators) { indicator.Source.SourceItems = sourceItems.Where(c => c.SourceId == indicator.SourceId).ToList(); } } var result = new DatetimeSerieModel { Start = period.Start, End = period.End, Name = journey.Name, Avatar = journey.Avatar, }; var aggregator = new JourneyDailyAggregate(journey, period); var(availability, features) = aggregator.MeasureQuality; result.Availability.AddItems( availability.OrderBy(c => c.Date).Select(c => (c.Date, c.Measure.Availability)).ToList() ); result.Latency.AddItems( availability.OrderBy(c => c.Date).Select(c => (c.Date, c.Measure.Latency)).ToList() ); result.Experience.AddItems( availability.OrderBy(c => c.Date).Select(c => (c.Date, c.Measure.Experience)).ToList() ); foreach (var(feature, avaValues) in features) { var pivotAvailability = new DatetimeSerieListModel(feature.Name, feature.Avatar); pivotAvailability.AddItems(avaValues.OrderBy(c => c.Date) .Select(c => (c.Date, QualityUtils.MeasureDebt(c.Measure.Availability, journey.AvailabilitySlo))).ToList()); result.AvailabilityDetail.Add(pivotAvailability); var pivotLatency = new DatetimeSerieListModel(feature.Name, feature.Avatar); pivotLatency.AddItems(avaValues.OrderBy(c => c.Date) .Select(c => (c.Date, QualityUtils.MeasureLatencyDebt(c.Measure.Latency, journey.LatencySlo))).ToList()); result.LatencyDetail.Add(pivotLatency); var pivotExperience = new DatetimeSerieListModel(feature.Name, feature.Avatar); pivotExperience.AddItems(avaValues.OrderBy(c => c.Date) .Select(c => (c.Date, QualityUtils.MeasureDebt(c.Measure.Experience, journey.ExperienceSlo))).ToList()); result.ExperienceDetail.Add(pivotExperience); } return(result); }
public DebtMeasureValue MeasureDebt(SLOValue slo) { return(new DebtMeasureValue() { Availability = QualityUtils.MeasureDebt(this.Availability, slo.Availability), Latency = QualityUtils.MeasureLatencyDebt(this.Latency, slo.Latency), Experience = QualityUtils.MeasureDebt(this.Experience, slo.Experience) }); }
public DebtMeasureValue MeasureDebt(DatePeriodValue period = null) { var measure = this.Measure(period); var maps = this.Indicators.Select(c => c.Feature.JourneyMaps).ToList(); var services = maps.SelectMany(c => c.Select(d => d.Journey)).Distinct(new JourneyEntityCompare()); decimal availabilityDebt = 0; decimal latencyDebt = 0; decimal experienceDebt = 0; foreach (var item in services) { availabilityDebt += QualityUtils.MeasureDebt(measure.Availability, item.AvailabilitySlo); latencyDebt += QualityUtils.MeasureLatencyDebt(measure.Latency, item.LatencySlo); experienceDebt += QualityUtils.MeasureDebt(measure.Experience, item.ExperienceSlo); } var result = new DebtMeasureValue(availabilityDebt, latencyDebt, experienceDebt); return(result); }