소스 검색

fixed performance in P5Menu

Piotr Labudda 8 년 전
부모
커밋
225c3baa5c
1개의 변경된 파일20개의 추가작업 그리고 2개의 파일을 삭제
  1. 20 2
      SE/se-lib/Route/P5Menu.php

+ 20 - 2
SE/se-lib/Route/P5Menu.php

@@ -49,6 +49,12 @@ class Route_P5Menu extends RouteBase {
 		$bookmarks = UserBookmarks::getInstance()->getBookmarks();
 		$bookmarks = UserBookmarks::getInstance()->getBookmarks();
 		$makeShortLabel = [ $this, 'getRawLabel' ];
 		$makeShortLabel = [ $this, 'getRawLabel' ];
 
 
+		$sqlIds = implode(", ", array_keys($listObjects));
+		$cacheZasobInfo = DB::getPDO()->fetchAllByKey("
+			select `ID`, `DESC`, `DESC_PL`, `OPIS`
+			from CRM_LISTA_ZASOBOW
+			where ID in ({$sqlIds})
+		", $key = 'ID');
 		return [
 		return [
 			'type' => 'success',
 			'type' => 'success',
 			'msg' => "OK",
 			'msg' => "OK",
@@ -56,13 +62,25 @@ class Route_P5Menu extends RouteBase {
 				'version' => $this->getVersion(),
 				'version' => $this->getVersion(),
 
 
 				'objects' => array_values( array_filter(
 				'objects' => array_values( array_filter(
-					array_map(function ($acl, $idZasob) use ($makeShortLabel) {
+					array_map(function ($acl, $idZasob) use ($makeShortLabel, $cacheZasobInfo) {
 						if (!$acl) return [
 						if (!$acl) return [
 							'id' => $idZasob,
 							'id' => $idZasob,
 							'TODO' => 'TODO'
 							'TODO' => 'TODO'
 						];
 						];
 
 
-						$zasobObj = ProcesHelper::getZasobTableInfo($acl->getID());
+						// $zasobObj = ProcesHelper::getZasobTableInfo($acl->getID());
+						// $zasobObj = (object)DB::getPDO()->fetchFirst("
+						// 	select `ID`, `DESC`, `DESC_PL`, `OPIS`
+						// 	from CRM_LISTA_ZASOBOW
+						// 	where ID = :id
+						// ", [ ':id' => $acl->getID() ]);
+						// if ((int)$idZasob !== (int)$acl->getID()) throw new Exception("BUG idZasob !== Acl->getID() : ({$idZasob}) !== (".$acl->getID().")");
+						if (!array_key_exists($acl->getID(), $cacheZasobInfo)) return [
+							'id' => $idZasob,
+							'TODO' => "Zasób '{$idZasob}' nie istnieje w bazie"
+						];
+
+						$zasobObj = (object)$cacheZasobInfo[$acl->getID()];
 						return [
 						return [
 							'id' => $acl->getID(),
 							'id' => $acl->getID(),
 							'namespace' => $acl->getNamespace(),
 							'namespace' => $acl->getNamespace(),