code optimization

This commit is contained in:
azhar bhat
2026-10-27 13:34:36 +05:30
parent fd99bc041d
commit 6aa9051507
2 changed files with 3 additions and 6 deletions

View File

@@ -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;
}
}

View File

@@ -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.';