예제 #1
0
        public (decimal utilization, int total, int assigned) MeasureUtilization()
        {
            var sources = this.Sources;

            if (sources.Count == 0)
            {
                return(1, 0, 0);
            }
            var total = sources.Count;
            var state = sources.ToDictionary(c => c.Id.Value, c => c.Name);

            foreach (var item in this.Features.SelectMany(c => c.Indicators))
            {
                if (state.ContainsKey(item.SourceId))
                {
                    state.Remove(item.SourceId);
                }
                if (state.Count == 0)
                {
                    break;
                }
            }
            var assigned = total - state.Count();

            return(QualityUtils.CalculateProportion(total, assigned), total, assigned);
        }
예제 #2
0
        public (decimal coverage, int total, int assigned) MeasureCoverage()
        {
            var features = this.Features;

            if (features.Count == 0)
            {
                return(1, 0, 0);
            }
            var total = features.Count;
            var state = features.ToDictionary(c => c.Id.Value, c => c.Name);

            foreach (var item in this.Journeys.SelectMany(c => c.FeatureMap))
            {
                if (state.ContainsKey(item.FeatureId))
                {
                    state.Remove(item.FeatureId);
                }
                if (state.Count == 0)
                {
                    break;
                }
            }
            var coverage = total - state.Count();

            return(QualityUtils.CalculateProportion(total, coverage), total, coverage);
        }
예제 #3
0
 public void Update(int total, int good, DateTime target)
 {
     this.Total   = total;
     this.Good    = good;
     this.Measure = QualityUtils.CalculateProportion(total, good);
     this.Target  = target;
 }
예제 #4
0
            public static SourceItemEntity CreateItem(SourceEntity source,
                                                      DateTime target, int?good, int?total, decimal?measeure,
                                                      DateTime on, string createdBy, SourceGroupEnum group)
            {
                if (measeure.HasValue)
                {
                    if (measeure < 0)
                    {
                        throw new ApplicationException(string.Format("invalid value measure {0} ", measeure));
                    }
                    if (group != SourceGroupEnum.Latency)
                    {
                        if (measeure > 1 || measeure < 0)
                        {
                            throw new ApplicationException(string.Format("proportion {0} must be between 0 and 1", measeure));
                        }
                    }
                }
                else if (good.HasValue && total.HasValue)
                {
                    if (good < 0 || total < 0)
                    {
                        throw new ApplicationException(
                                  string.Format("good {0} and total {1} must be greater equal than zero", good, total));
                    }
                    if (total < good)
                    {
                        throw new ApplicationException(
                                  string.Format("good {0} is greater than total {1}", good, total));
                    }
                    measeure = QualityUtils.CalculateProportion(total, good);
                }
                else
                {
                    throw new ApplicationException($" no values for measures ${total}, ${good}, ${measeure}");
                }

                var entity = new SourceItemEntity()
                {
                    Target     = target,
                    Good       = good,
                    Total      = total,
                    Measure    = measeure.Value,
                    Source     = source,
                    CreatedBy  = createdBy,
                    ModifiedBy = createdBy,
                    CreatedOn  = on,
                    ModifiedOn = on,
                    Group      = group
                };

                return(entity);
            }
        public (decimal ownership, int total, int assigned) Measure()
        {
            if (this.Features.Count() == 0)
            {
                return(1, 0, 0);
            }
            var total = this.Features.Count();
            var state = this.Features.ToDictionary(c => c.Id.Value, c => c.Name);

            foreach (var item in this.Squads.SelectMany(c => c.FeatureMaps))
            {
                if (state.ContainsKey(item.FeatureId))
                {
                    state.Remove(item.FeatureId);
                }
                if (state.Count == 0)
                {
                    break;
                }
            }
            var assigned = total - state.Count();

            return(QualityUtils.CalculateProportion(total, assigned), total, assigned);
        }
예제 #6
0
        public void LoadData(int month, int good, int total)
        {
            switch (month)
            {
            case 1:
                this.JanGood       = good;
                this.JanTotal      = total;
                this.JanProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 2:
                this.FebGood       = good;
                this.FebTotal      = total;
                this.FebProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 3:
                this.MarGood       = good;
                this.MarTotal      = total;
                this.MarProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 4:
                this.AprGood       = good;
                this.AprTotal      = total;
                this.AprProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 5:
                this.MayGood       = good;
                this.MayTotal      = total;
                this.MayProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 6:
                this.JunGood       = good;
                this.JunTotal      = total;
                this.JunProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 7:
                this.JulGood       = good;
                this.JulTotal      = total;
                this.JulProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 8:
                this.AugGood       = good;
                this.AugTotal      = total;
                this.AugProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 9:
                this.SepGood       = good;
                this.SepTotal      = total;
                this.SepProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 10:
                this.OctGood       = good;
                this.OctTotal      = total;
                this.OctProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 11:
                this.NovGood       = good;
                this.NovTotal      = total;
                this.NovProportion = QualityUtils.CalculateProportion(total, good);
                break;

            case 12:
                this.DecGood       = good;
                this.DecTotal      = total;
                this.DecProportion = QualityUtils.CalculateProportion(total, good);
                break;

            default:
                break;
            }
        }
예제 #7
0
        public async Task <OperationProductDashboardRp> GetProductDashboard(int productId,
                                                                            DateTime start, DateTime end)
        {
            var product = await this._dbContext.FullLoadProduct(productId);

            var squadsData = await this._dbContext.SquadFeatures
                             .Include(c => c.Squad)
                             .Where(c => c.Feature.ProductId == productId).ToListAsync();

            var incidentsData = await this._dbContext.IncidentMaps
                                .Include(c => c.Incident)
                                .Where(c => c.Feature.ProductId == productId).ToListAsync();


            var sourceItems = await this._dbContext.GetSourceItemsByProduct(productId, start, end);

            var result = new OperationProductDashboardRp();

            foreach (var source in product.Sources)
            {
                source.SourceItems = sourceItems.Where(c => c.SourceId == source.Id).ToList();
                var measure = source.Measure();

                result.Sources.Add(new SourceGetListRp()
                {
                    Id        = source.Id.Value,
                    Measure   = measure,
                    Avatar    = source.Avatar,
                    CreatedBy = source.CreatedBy,
                    CreatedOn = source.CreatedOn.Value,
                    AvailabilityDefinition = source.AvailabilityDefinition,
                    LatencyDefinition      = source.LatencyDefinition,
                    ExperienceDefinition   = source.ExperienceDefinition,
                    Name = source.Name
                });
            }

            foreach (var feature in product.Features)
            {
                foreach (var indicator in feature.Indicators)
                {
                    indicator.Source = product.Sources.Single(c => c.Id == indicator.SourceId);
                }
                foreach (var squadMap in squadsData.Where(c => c.FeatureId == feature.Id).ToList())
                {
                    squadMap.Feature = feature;
                    feature.Squads.Add(squadMap);
                }

                var tmp     = this._mapper.Map <FeatureGetListRp>(feature);
                var measure = feature.Measure();
                tmp.LoadMeasure(measure);
                result.Features.Add(tmp);

                var featureIncidents = incidentsData.Where(c => c.FeatureId == feature.Id)
                                       .Select(c => c.Incident).ToList();
                var incidentAggregate = new IncidentMetricAggregate(featureIncidents);

                var aggIncident = incidentAggregate.Metrics();
                result.IncidentInformation[feature.Id.Value] = new
                {
                    count = featureIncidents.Count,
                    mttd  = aggIncident.mttd,
                    mtte  = aggIncident.mtte,
                    mttf  = aggIncident.mttf,
                    mttm  = aggIncident.mttm
                };

                result.FeatureMaps[feature.Id.Value] = feature.Indicators.OrderBy(c => c.Id).Select(c => c.SourceId).ToList();
                result.SquadMaps[feature.Id.Value]   = squadsData.Where(c => c.FeatureId == feature.Id)
                                                       .Select(c => c.SquadId)
                                                       .Distinct().ToList();
            }

            foreach (var squad in squadsData.Select(c => c.Squad).Distinct(new SquadCompare()))
            {
                var tmp = this._mapper.Map <SquadGetListRp>(squad);
                result.Squads.Add(tmp);
            }

            int sloFails = 0;

            foreach (var journey in product.Journeys)
            {
                foreach (var map in journey.FeatureMap)
                {
                    map.Feature = product.Features.Single(c => c.Id == map.FeatureId);
                }

                var measure = journey.Measure();

                if (measure.Availability < journey.AvailabilitySlo)
                {
                    sloFails += 1;
                }

                var tmp = this._mapper.Map <JourneyGetListRp>(journey);
                result.Journeys.Add(tmp);
                result.JourneyMaps[journey.Id.Value] = journey.FeatureMap.OrderBy(c => c.Id).Select(c => c.FeatureId).ToList();
            }

            result.Journeys      = result.Journeys.OrderBy(c => c.Availability).ToList();
            result.SLOFail       = sloFails;
            result.SLOProportion = QualityUtils.CalculateFailProportion(product.Journeys.Count, sloFails);
            //TODO: change
            //result.SourceStats = new StatsValue(result.Sources.Select(c => c.Measure));
            result.FeaturesStats    = new StatsValue(result.Features.Select(c => c.Availability));
            result.FeaturesCoverage = QualityUtils.CalculateProportion(product.Features.Count,
                                                                       squadsData.Select(c => c.FeatureId).Distinct().Count());

            result.JourneysStats = new StatsValue(result.Journeys.Select(c => c.Availability));
            return(result);
        }