Exemple #1
0
        public async Task <List <Responses.Indicator> > GetAllIndicators(string userId, IndicatorType indicatorType)
        {
            // Get user
            var user = await _userRepository.GetSingle(userId);

            // Check if it exists
            if (user == null)
            {
                throw new NotFoundException(UserMessage.UserNotFound);
            }

            // Get all indicators
            var indicators = await _indicatorRepository.GetAll(IndicatorExpression.IndicatorFilter(indicatorType, null, userId));

            // Get all indicator dependencies
            var indicatorDependencies = await _indicatorDependencyRepository.GetAll();

            // Build indicator dependencies
            IndicatorBuilder.BuildDependencies(indicators, indicatorDependencies);

            // Response
            var response = _mapper.Map <List <Responses.Indicator> >(indicators);

            // Return
            return(response);
        }
Exemple #2
0
        public async Task <List <Indicator> > UpdateIndicatorDependencies()
        {
            // Start watch
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            // Get all indicators
            var indicators = await _indicatorRepository.GetAll();

            // Get all indicator dependencies
            var indicatorDependencies = await _indicatorDependencyRepository.GetAll();

            // Build indicator dependencies
            IndicatorBuilder.BuildDependencies(indicators, indicatorDependencies);

            // Build dependency levels
            IndicatorBuilder.BuildDependencyLevels(indicators, indicatorDependencies);

            // Update
            _indicatorRepository.UpdateRange(indicators);

            // Save
            await _dbContext.SaveChangesAsync();

            // Build max dependency level
            var maxDependencyLevel = IndicatorBuilder.BuildMaxDependencyLevel(indicators);

            // Stop watch
            stopwatch.Stop();

            // Log into Splunk
            _logger.LogSplunkInformation("UpdateIndicatorDependencies", new
            {
                MaxLevel      = maxDependencyLevel,
                ExecutionTime = stopwatch.Elapsed.TotalSeconds
            });

            // Return
            return(indicators);
        }