code optimization
This commit is contained in:
@@ -101,7 +101,6 @@ class QghcApiLog extends ObjectModel
|
||||
if (!Db::getInstance()->delete('qghc_api_log', '`date_add` < \'' . pSQL($cutoff) . '\'')) {
|
||||
return false;
|
||||
}
|
||||
$count = (int) Db::getInstance()->Affected_Rows();
|
||||
|
||||
// Daily file logs follow the same retention window as the DB rows.
|
||||
$logDir = _PS_MODULE_DIR_ . 'qlogooglehotelconnector/logs/';
|
||||
@@ -114,6 +113,6 @@ class QghcApiLog extends ObjectModel
|
||||
}
|
||||
}
|
||||
|
||||
return array('count' => $count, 'cutoff' => $cutoff);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,10 +38,8 @@ if ($token !== Tools::encrypt('qlogooglehotelconnector')) {
|
||||
|
||||
// Delete qghc_api_log rows and daily file logs older than 2 months
|
||||
Module::getInstanceByName('qlogooglehotelconnector'); // loads the module classes
|
||||
$result = QghcApiLog::cleanupApiLogs();
|
||||
|
||||
if ($result !== false) {
|
||||
echo 'OK — ' . (int)$result['count'] . ' log(s) deleted (older than ' . $result['cutoff'] . ').';
|
||||
if (QghcApiLog::cleanupApiLogs()) {
|
||||
echo 'OK — logs older than 2 months deleted.';
|
||||
} else {
|
||||
header('HTTP/1.1 500 Internal Server Error');
|
||||
echo 'ERROR — failed to delete old logs.';
|
||||
|
||||
Reference in New Issue
Block a user