diff --git a/modules/custom/openy_repeat/src/Controller/RepeatController.php b/modules/custom/openy_repeat/src/Controller/RepeatController.php index 28f4e87f9b..e05cef0ef5 100644 --- a/modules/custom/openy_repeat/src/Controller/RepeatController.php +++ b/modules/custom/openy_repeat/src/Controller/RepeatController.php @@ -178,7 +178,13 @@ public function ajaxScheduler( Request $request, $location, $date, $category) { $result = $query->fetchAll(); $locations_info = $this->getLocationsInfo(); - $classes_info = $this->getClassesInfo(); + + $classesIds = []; + foreach ($result as $key => $item) { + $classesIds[$item->class] = $item->class; + } + $classes_info = $this->getClassesInfo($classesIds); + foreach ($result as $key => $item) { $result[$key]->location_info = $locations_info[$item->location]; $result[$key]->class_info = $classes_info[$item->class]; @@ -259,18 +265,14 @@ public function getLocationsInfo() { /** * Get detailed info about Class. */ - public function getClassesInfo() { + public function getClassesInfo($nids) { $data = []; - $tags = ['node_list']; - $cid = 'openy_repeat:classes_info'; + $tags = []; + $cid = 'openy_repeat:classes_info' . md5(json_encode($nids)); if ($cache = $this->cache->get($cid)) { $data = $cache->data; } else { - $nids = $this->entityQuery - ->get('node') - ->condition('type','class') - ->execute(); $nids_chunked = array_chunk($nids, 20, TRUE); foreach ($nids_chunked as $chunk) { $classes = $this->entityTypeManager->getStorage('node')->loadMultiple($chunk);