@@ -99,8 +99,27 @@ public static function getOpPerformance(array $params): array {
9999 }
100100 }
101101
102+ $ userIds = array_column ($ depPerformanceRows , 'id ' );
103+ $ depPerformanceRowsById = array_column ($ depPerformanceRows , null , 'id ' );
104+ $ depPerformanceRows = [];
105+
106+ if (!empty ($ userIds )) {
107+ $ usersQuery = [
108+ 'filterin ' => ['id ' => $ userIds ],
109+ 'sort ' => 'name ASC, surname ASC ' ,
110+ 'limit ' => $ limitList > 0 ? $ limitList : false ,
111+ ];
112+ $ users = \erLhcoreClassModelUser::getList ($ usersQuery );
113+ foreach ($ users as $ user ) {
114+ if (isset ($ depPerformanceRowsById [$ user ->id ])) {
115+ $ row = $ depPerformanceRowsById [$ user ->id ];
116+ $ row ['name ' ] = $ user ->name_official ;
117+ $ depPerformanceRows [] = $ row ;
118+ }
119+ }
120+ }
121+
102122 foreach ($ depPerformanceRows as &$ rowPerformance ) {
103- $ rowPerformance ['name ' ] = ($ user = \erLhcoreClassModelUser::fetch ($ rowPerformance ['id ' ], true )) ? $ user ->name_official : '' ;
104123 foreach ($ performanceColumns as $ columnPerformance ) {
105124 if (!isset ($ rowPerformance [$ columnPerformance ])) {
106125 $ rowPerformance [$ columnPerformance ] = '' ;
@@ -109,16 +128,7 @@ public static function getOpPerformance(array $params): array {
109128 }
110129 }
111130 }
112-
113- usort ($ depPerformanceRows , function ($ rowA , $ rowB ) {
114- $ nameA = isset ($ rowA ['name ' ]) ? (string )$ rowA ['name ' ] : '' ;
115- $ nameB = isset ($ rowB ['name ' ]) ? (string )$ rowB ['name ' ] : '' ;
116- return strcasecmp ($ nameA , $ nameB );
117- });
118-
119- if ($ limitList > 0 ) {
120- $ depPerformanceRows = array_slice ($ depPerformanceRows , 0 , $ limitList );
121- }
131+ unset($ rowPerformance );
122132
123133 $ performanceUpdateInterval = isset ($ storedPerformanceConfig ['update_interval ' ])
124134 && in_array ((int )$ storedPerformanceConfig ['update_interval ' ], self ::VALID_UPDATE_INTERVALS )
@@ -130,7 +140,7 @@ public static function getOpPerformance(array $params): array {
130140 'cl ' => $ performanceColumns ,
131141 'ui ' => $ performanceUpdateInterval ,
132142 'up ' => $ updatedAt ,
133- 'tt ' => \erLhcoreClassModule::getDifference ($ startTimeRequestItem , microtime ()),
143+ 'tt_stat ' => \erLhcoreClassModule::getDifference ($ startTimeRequestItem , microtime ()),
134144 ];
135145 }
136146
@@ -206,14 +216,29 @@ public static function getDepPerformance(array $params): array {
206216 }
207217 }
208218
219+ $ depIds = array_column ($ depPerformanceRows , 'id ' );
209220 if ($ allowedDepIds !== null ) {
210- $ depPerformanceRows = array_values (array_filter ($ depPerformanceRows , function ($ row ) use ($ allowedDepIds ) {
211- return isset ($ row ['id ' ]) && in_array ($ row ['id ' ], $ allowedDepIds );
212- }));
221+ $ depIds = array_values (array_intersect ($ depIds , $ allowedDepIds ));
222+ }
223+ $ depPerformanceRowsById = array_column ($ depPerformanceRows , null , 'id ' );
224+ $ depPerformanceRows = [];
225+
226+ if (!empty ($ depIds )) {
227+ $ departments = \erLhcoreClassModelDepartament::getList ([
228+ 'filterin ' => ['id ' => $ depIds ],
229+ 'sort ' => 'name ASC ' ,
230+ 'limit ' => $ limitList > 0 ? $ limitList : false ,
231+ ]);
232+ foreach ($ departments as $ department ) {
233+ if (isset ($ depPerformanceRowsById [$ department ->id ])) {
234+ $ row = $ depPerformanceRowsById [$ department ->id ];
235+ $ row ['name ' ] = $ department ->name ;
236+ $ depPerformanceRows [] = $ row ;
237+ }
238+ }
213239 }
214240
215241 foreach ($ depPerformanceRows as &$ rowPerformance ) {
216- $ rowPerformance ['name ' ] = (string )\erLhcoreClassModelDepartament::fetch ($ rowPerformance ['id ' ], true );
217242 foreach ($ performanceColumns as $ columnPerformance ) {
218243 if (!isset ($ rowPerformance [$ columnPerformance ])) {
219244 $ rowPerformance [$ columnPerformance ] = '' ;
@@ -222,16 +247,7 @@ public static function getDepPerformance(array $params): array {
222247 }
223248 }
224249 }
225-
226- usort ($ depPerformanceRows , function ($ rowA , $ rowB ) {
227- $ nameA = isset ($ rowA ['name ' ]) ? (string )$ rowA ['name ' ] : '' ;
228- $ nameB = isset ($ rowB ['name ' ]) ? (string )$ rowB ['name ' ] : '' ;
229- return strcasecmp ($ nameA , $ nameB );
230- });
231-
232- if ($ limitList > 0 ) {
233- $ depPerformanceRows = array_slice ($ depPerformanceRows , 0 , $ limitList );
234- }
250+ unset($ rowPerformance );
235251
236252 $ performanceUpdateInterval = isset ($ storedPerformanceConfig ['update_interval ' ])
237253 && in_array ((int )$ storedPerformanceConfig ['update_interval ' ], self ::VALID_UPDATE_INTERVALS )
@@ -243,7 +259,7 @@ public static function getDepPerformance(array $params): array {
243259 'cl ' => $ performanceColumns ,
244260 'ui ' => $ performanceUpdateInterval ,
245261 'up ' => $ updatedAt ,
246- 'tt ' => \erLhcoreClassModule::getDifference ($ startTimeRequestItem , microtime ()),
262+ 'tt_stat ' => \erLhcoreClassModule::getDifference ($ startTimeRequestItem , microtime ()),
247263 ];
248264 }
249265}
0 commit comments