]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-495 очистка логов открытия страниц feature_filippov_erp-495_clear_log_open_page origin/feature_filippov_erp-495_clear_log_open_page
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Wed, 3 Dec 2025 07:18:50 +0000 (10:18 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Wed, 3 Dec 2025 07:18:50 +0000 (10:18 +0300)
erp24/commands/CronClearController.php

index e58c734f39ac71d14634598530b517ea2f42ee09..8ed337cedc9d1f580dd4142216c485811aab825e 100644 (file)
@@ -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";