From fa3cb724d1e3df4f48959411a7fed2974240d58f Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Wed, 3 Dec 2025 10:18:50 +0300 Subject: [PATCH] =?utf8?q?ERP-495=20=D0=BE=D1=87=D0=B8=D1=81=D1=82=D0=BA?= =?utf8?q?=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=BE=D0=B2=20=D0=BE=D1=82=D0=BA?= =?utf8?q?=D1=80=D1=8B=D1=82=D0=B8=D1=8F=20=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?utf8?q?=D0=B8=D1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/commands/CronClearController.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/erp24/commands/CronClearController.php b/erp24/commands/CronClearController.php index e58c734f..8ed337ce 100644 --- a/erp24/commands/CronClearController.php +++ b/erp24/commands/CronClearController.php @@ -38,6 +38,30 @@ class CronClearController extends Controller echo "Successfully deleted {$deletedCount} old API log records\n"; + return ExitCode::OK; + } catch (\Exception $e) { + echo "Error during cleanup: " . $e->getMessage() . "\n"; + return ExitCode::UNSPECIFIED_ERROR; + } + } + /** + * Clear old page statistics older than 4 months + * @return int Exit code + */ + public function actionClearOldPageStatistics() + { + echo "Starting cleanup of old page statistics...\n"; + + try { + $sql = "DELETE FROM public.page_statistics WHERE created_at < NOW() - INTERVAL '4 months'"; + $command = Yii::$app->db->createCommand($sql); + + echo "Executing SQL: {$command->rawSql}\n"; + + $deletedCount = $command->execute(); + + echo "Successfully deleted {$deletedCount} old page statistics records\n"; + return ExitCode::OK; } catch (\Exception $e) { echo "Error during cleanup: " . $e->getMessage() . "\n"; -- 2.39.5