From: Aleksey Filippov Date: Wed, 3 Dec 2025 07:18:50 +0000 (+0300) Subject: ERP-495 очистка логов открытия страниц X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=fa3cb724d1e3df4f48959411a7fed2974240d58f;p=erp24_rep%2Fyii-erp24%2F.git ERP-495 очистка логов открытия страниц --- 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";