From 6aa9051507385bf015f07d1e49cabe6c7b922425 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Tue, 27 Oct 2026 13:34:36 +0530 Subject: [PATCH] code optimization --- modules/qlogooglehotelconnector/classes/QghcApiLog.php | 3 +-- modules/qlogooglehotelconnector/ghclogcron.php | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/modules/qlogooglehotelconnector/classes/QghcApiLog.php b/modules/qlogooglehotelconnector/classes/QghcApiLog.php index 4c1a6c072..a4641420d 100644 --- a/modules/qlogooglehotelconnector/classes/QghcApiLog.php +++ b/modules/qlogooglehotelconnector/classes/QghcApiLog.php @@ -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; } } diff --git a/modules/qlogooglehotelconnector/ghclogcron.php b/modules/qlogooglehotelconnector/ghclogcron.php index 87269090a..a00912974 100644 --- a/modules/qlogooglehotelconnector/ghclogcron.php +++ b/modules/qlogooglehotelconnector/ghclogcron.php @@ -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.';