예제 #1
0
        public void SquadPointsSuccess()
        {
            var squad = new SquadPointsAggregate(new SquadEntity()
            {
                FeatureMaps = new List <SquadFeatureEntity>()
                {
                    new SquadFeatureEntity()
                    {
                        Feature = new FeatureEntity()
                        {
                            Id          = 1,
                            Name        = "test",
                            JourneyMaps = new List <JourneyMapEntity>()
                            {
                                new JourneyMapEntity()
                                {
                                    Journey = new JourneyEntity()
                                    {
                                        AvailabilitySlo = 0.99m
                                    }
                                }
                            },
                            Indicators = new List <IndicatorEntity>()
                            {
                                new IndicatorEntity()
                                {
                                    Id     = 1,
                                    Source = new SourceEntity()
                                    {
                                        SourceItems = new List <SourceItemEntity>()
                                        {
                                            new SourceItemEntity()
                                            {
                                                Good   = 800, Total = 1000,
                                                Target = OwlveyCalendar.January201903
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });

            var result = squad.Measure();

            Assert.NotEmpty(result);
        }
예제 #2
0
        public async Task <SquadQualityGetRp> GetSquadByIdWithQuality(int id, DatePeriodValue period)
        {
            var entity = await this._dbContext.Squads
                         .Include(c => c.Members).ThenInclude(c => c.User)
                         .Include(c => c.FeatureMaps).ThenInclude(c => c.Feature)
                         .SingleOrDefaultAsync(c => c.Id == id);

            var members = await this._dbContext.Members.Include(c => c.User)
                          .Where(c => c.SquadId == id)
                          .ToListAsync();

            var validProducts = entity.FeatureMaps.Select(c => c.Feature.ProductId).Distinct();

            var products = new List <ProductEntity>();

            foreach (var item in validProducts)
            {
                var tmp = await this._dbContext.FullLoadProductWithSourceItems(item, period.Start, period.End);

                products.Add(tmp);
            }
            foreach (var item in entity.FeatureMaps)
            {
                foreach (var product in products)
                {
                    var tmp = product.Features.Where(c => c.Id == item.FeatureId).SingleOrDefault();
                    if (tmp != null)
                    {
                        item.Feature = tmp;
                        break;
                    }
                }
            }

            var agg           = new SquadPointsAggregate(entity);
            var squadMeasures = agg.Measure();

            var result = this._mapper.Map <SquadQualityGetRp>(entity);

            result.Members = this._mapper.Map <IEnumerable <UserGetListRp> >(members.Select(c => c.User).Distinct(new UserEntityCompare()));

            foreach (var item in squadMeasures)
            {
                var tmp = new FeatureBySquadRp()
                {
                    Id            = item.feature.Id.Value,
                    Description   = item.feature.Description,
                    Avatar        = item.feature.Avatar,
                    CreatedBy     = item.feature.CreatedBy,
                    CreatedOn     = item.feature.CreatedOn,
                    Debt          = item.debt,
                    Quality       = item.quality,
                    ProductId     = item.product.Id.Value,
                    Product       = item.product.Name,
                    JourneyId     = item.journey.Id.Value,
                    JourneyAvatar = item.journey.Avatar,
                };
                tmp.Name    = item.feature.Name;
                tmp.SLO     = item.journey.GetSLO();
                tmp.Journey = item.journey.Name;
                result.Features.Add(tmp);
            }
            result.Features = result.Features.OrderBy(c => c.Journey).ToList();
            return(result);
        }