refactor(api): get statistics

This commit is contained in:
grandeljay 2023-04-24 12:46:04 +02:00
parent 4efe2b6ba6
commit df1ffe799e

View file

@ -29,14 +29,15 @@ switch ($_SERVER['REQUEST_METHOD']) {
foreach ($tables as $table) { foreach ($tables as $table) {
/** Get count */ /** Get count */
$count = new Cache\Query( $countQuery = new Cache\Query(
'SELECT COUNT(`id`) AS "count" 'SELECT COUNT(`id`) AS "count"
FROM `' . $table . '`;', FROM `' . $table . '`;',
array(), array(),
Duration::DAY Duration::DAY
); );
$response['data'][$table] = $count->get(); $count = $countQuery->get();
$response['data'][$table] = $count;
/** Get last modified */ /** Get last modified */
$user_time_zome = new \IntlDateFormatter( $user_time_zome = new \IntlDateFormatter(
@ -50,7 +51,7 @@ switch ($_SERVER['REQUEST_METHOD']) {
\IntlDateFormatter::SHORT, \IntlDateFormatter::SHORT,
$user_time_zome $user_time_zome
); );
$response['data']['modified'] = $datetimeFormatter->format($count->getLastModified()); $response['data']['modified'] = $datetimeFormatter->format($countQuery->getLastModified());
} }
} else { } else {
$table = Sanitiser::getTable($_GET['table']); $table = Sanitiser::getTable($_GET['table']);