public async Task <IActionResult> Index(int?id) { var test = id.HasValue ? await _testService.GetTestById(id.Value) : await _testService.GetLastTest(); var allTests = await _testService.GetAll(); var allGenerations = await _generationService.GetAll(test.Id); var bestGenerations = await _generationService.GetBest(test.Id, 25); var allChromosomes = await _chromosomeService.GetAll(test.Id); var bestChromosomes = await _chromosomeService.GetBest(test.Id, 25); var generationFitnessData = _chartJsService.GenerateGenerationFitnessData(allGenerations); var chromosomeFitnessData = _chartJsService.GenerateChromosomeFitnessData(allChromosomes); var averageElapsedTimeData = _chartJsService.GenerateAverageElapsedTimeData(allGenerations); var averageDepthData = _chartJsService.GenerateAverageDepthData(allChromosomes); var averageNodesData = _chartJsService.GenerateAverageNodesData(allChromosomes); var averageTimePerGameData = _chartJsService.GenerateAverageTimePerGameData(allChromosomes); return(View(new MainViewModel { CurrentTest = _mapper.Map <TestViewModel>(test), Tests = _mapper.Map <List <TestViewModel> >(allTests), AllGenerations = _mapper.Map <List <GenerationViewModel> >(allGenerations), BestGenerations = _mapper.Map <List <GenerationViewModel> >(bestGenerations), AllChromosomes = _mapper.Map <List <ChromosomeViewModel> >(allChromosomes), BestChromosomes = _mapper.Map <List <ChromosomeViewModel> >(bestChromosomes), GenerationFitnessChartJson = JsonConvert.SerializeObject(generationFitnessData), ChromosomeFitnessChartJson = JsonConvert.SerializeObject(chromosomeFitnessData), AverageElapsedTimeChartJson = JsonConvert.SerializeObject(averageElapsedTimeData), AverageDepthChartJson = JsonConvert.SerializeObject(averageDepthData), AverageNodesChartJson = JsonConvert.SerializeObject(averageNodesData), AverageTimePerGameChartJson = JsonConvert.SerializeObject(averageTimePerGameData) })); }
/// <summary> /// Returns all generations. /// </summary> public async Task <GenerationEntry[]> GetGenerations() { Logger.LogInformation("Getting generations..."); return(await GenerationService.GetAll()); }