public async Task <CustomerDashboardRp> GetCustomersDashboardProductJourneys(DateTime?start, DateTime?end)
        {
            var result = new CustomerDashboardRp();

            result = await this.InternalGetDashboardCustomersProductJourneys(start, end);

            var(bs, be, ps, pe) = DateTimeUtils.CalculateBeforePreviousDates(start, end);

            var before = await this.InternalGetDashboardCustomersProductJourneys(bs, be);

            var previous = await this.InternalGetDashboardCustomersProductJourneys(ps, pe);

            foreach (var product in result.Products)
            {
                var target_product = previous.Products.Where(c => c.ProductId == product.ProductId).SingleOrDefault();
                if (target_product != null)
                {
                    product.Previous = target_product.Effectiveness;
                }
                var target_before = before.Products.Where(c => c.ProductId == product.ProductId).SingleOrDefault();
                if (target_before != null)
                {
                    product.Before = target_before.Effectiveness;
                }
            }
            return(result);
        }
        private async Task <CustomerDashboardRp> InternalGetDashboardCustomersProductJourneys(DateTime?start, DateTime?end)
        {
            var result    = new CustomerDashboardRp();
            var customers = await this._dbContext.Customers
                            .Include(c => c.Products)
                            .ThenInclude(c => c.Journeys)
                            .ThenInclude(c => c.FeatureMap)
                            .ThenInclude(c => c.Feature)
                            .ThenInclude(c => c.Indicators)
                            .ThenInclude(c => c.Source)
                            .ToListAsync();

            var sourceItems = await this._dbContext.GetSourceItems(start.Value, end.Value);

            foreach (var customer in customers)
            {
                foreach (var product in customer.Products)
                {
                    var productResult = new CustomerDashboardRp.CustomerProductRp(product);

                    foreach (var journey in product.Journeys)
                    {
                        foreach (var featureMap in journey.FeatureMap)
                        {
                            foreach (var indicator in featureMap.Feature.Indicators)
                            {
                                var target = sourceItems.Where(c => c.SourceId == indicator.SourceId).ToList();
                                indicator.Source.SourceItems = target;
                            }
                        }
                        journey.Measure();
                        var journeyResult = new CustomerDashboardRp.CustomerJourneyRp(journey);
                        productResult.Journeys.Add(journeyResult);
                    }
                    result.Products.Add(productResult);
                }
            }
            return(result);
        }