public async Task <List <Indicator> > UpdateDependencyLevels() { // Start watch var stopwatch = new Stopwatch(); stopwatch.Start(); // Get all indicators var indicators = await _mainDbContext.Indicators.ToListAsync(); // Get all indicators dependencies var indicatorDependencies = await _mainDbContext.IndicatorDependencies.ToListAsync(); // Build dependency levels IndicatorBuilder.BuildDependencyLevels(indicators, indicatorDependencies); // Update _mainDbContext.Indicators.UpdateRange(indicators); // Save await _mainDbContext.SaveChangesAsync(); // Build max dependency level var maxDependencyLevel = IndicatorBuilder.BuildMaxDependencyLevel(indicators); // Stop watch stopwatch.Stop(); // Log _logger.LogInformation("{@Event}, {@MaxLevel}, {@ExecutionTime}", "DependenciesLevelsUpdated", maxDependencyLevel, stopwatch.Elapsed.TotalSeconds); // Return return(indicators); }
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); }