1313 **/
1414
1515use App \ModelSerializers \SerializerUtils ;
16+ use http \Env \Response ;
1617use Illuminate \Support \Facades \Request ;
18+ use Illuminate \Support \Facades \Session ;
1719use Illuminate \Support \Facades \Validator ;
1820use libs \utils \PaginationValidationRules ;
1921use models \exceptions \ValidationException ;
@@ -119,7 +121,7 @@ public function _getAll
119121 $ order = call_user_func ($ defaultOrderRules );
120122 }
121123 }
122-
124+ $ dbStart = microtime ( true );
123125 if (!is_null ($ queryCallable ))
124126 $ data = call_user_func ($ queryCallable ,
125127 $ page ,
@@ -136,21 +138,26 @@ public function _getAll
136138 $ order ,
137139 $ applyExtraFilters
138140 );
139-
141+ $ dbEnd = (microtime (true )-$ dbStart )*1000 ;
142+ $ transformStart = microtime (true );
140143 $ serializerParams ['filter ' ] = $ filter ;
141-
142- return $ this ->ok
144+ $ res = $ data ->toArray
143145 (
144- $ data ->toArray
145- (
146- SerializerUtils::getExpand (),
147- SerializerUtils::getFields (),
148- SerializerUtils::getRelations (),
149- $ serializerParams ,
150- $ serializerType && is_callable ($ serializerType ) ? call_user_func ($ serializerType ) : SerializerRegistry::SerializerType_Public
151- )
146+ SerializerUtils::getExpand (),
147+ SerializerUtils::getFields (),
148+ SerializerUtils::getRelations (),
149+ $ serializerParams ,
150+ $ serializerType && is_callable ($ serializerType ) ? call_user_func ($ serializerType ) : SerializerRegistry::SerializerType_Public
152151 );
153-
152+ $ transformEnd = (microtime (true )-$ transformStart )*1000 ;
153+ $ encodeStart = microtime (true );
154+ $ json_response = $ this ->ok ($ res );
155+ $ encodeEnd = (microtime (true )-$ encodeStart )*1000 ;
156+ Session::put ("db_time " , $ dbEnd );
157+ Session::put ("transform_time " , $ transformEnd );
158+ Session::put ("encode_time " , $ encodeEnd );
159+ Session::save ();
160+ return $ json_response ;
154161 });
155162 }
156163
@@ -272,4 +279,4 @@ public function _getAllCSV
272279
273280 });
274281 }
275- }
282+ }
0 commit comments