add query time to get_items API response

This commit is contained in:
Leo Germani 2018-08-02 21:52:51 -03:00
parent 14f5591640
commit ae6bf8ff88
1 changed files with 7 additions and 1 deletions

View File

@ -216,9 +216,13 @@ class REST_Items_Controller extends REST_Controller {
if($request['collection_id']) {
$collection_id = $request['collection_id'];
}
$query_start = microtime(true);
$items = $this->items_repository->fetch($args, $collection_id, 'WP_Query');
$query_end = microtime(true);
$response = [];
$return_template = false;
@ -274,6 +278,8 @@ class REST_Items_Controller extends REST_Controller {
$rest_response->header('X-WP-Total', (int) $total_items);
$rest_response->header('X-WP-TotalPages', (int) $max_pages);
$rest_response->header('X-Tainacan-Query-Time', $query_end - $query_start);
$rest_response->header('X-Tainacan-Elapsed-Time', microtime(true) - $query_start);
return $rest_response;
}