From e4efaf1efa36ac2aa8cd3754e9cca29aecaa2d4d Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Fri, 17 Jan 2025 22:53:31 +0530 Subject: [PATCH] fix: maintenance job missing type --- .env | 2 +- src/Appwrite/Platform/Tasks/Maintenance.php | 17 +++++------------ src/Appwrite/Platform/Workers/Deletes.php | 3 +++ 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/.env b/.env index 8f7d7996e7..53a93b5fb2 100644 --- a/.env +++ b/.env @@ -79,7 +79,7 @@ _APP_FUNCTIONS_RUNTIMES_NETWORK=runtimes _APP_EXECUTOR_SECRET=your-secret-key _APP_EXECUTOR_HOST=http://proxy/v1 _APP_FUNCTIONS_RUNTIMES=php-8.0,node-18.0,python-3.9,ruby-3.1 -_APP_MAINTENANCE_INTERVAL=86400 +_APP_MAINTENANCE_INTERVAL=60 _APP_MAINTENANCE_DELAY= _APP_MAINTENANCE_RETENTION_CACHE=2592000 _APP_MAINTENANCE_RETENTION_EXECUTION=1209600 diff --git a/src/Appwrite/Platform/Tasks/Maintenance.php b/src/Appwrite/Platform/Tasks/Maintenance.php index a7558934b5..2d37bdbf70 100644 --- a/src/Appwrite/Platform/Tasks/Maintenance.php +++ b/src/Appwrite/Platform/Tasks/Maintenance.php @@ -47,9 +47,12 @@ class Maintenance extends Action Console::info("[{$time}] Notifying workers with maintenance tasks every {$interval} seconds"); $this->foreachProject($dbForPlatform, function (Document $project) use ($queueForDeletes, $usageStatsRetentionHourly) { - $queueForDeletes->setProject($project); + $queueForDeletes + ->setType(DELETE_TYPE_MAINTENANCE) + ->setProject($project) + ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) + ->trigger(); - $this->notifyProjects($queueForDeletes, $usageStatsRetentionHourly); }); $this->notifyDeleteConnections($queueForDeletes); @@ -59,16 +62,6 @@ class Maintenance extends Action }, $interval, $delay); } - /** - * Hook to allow sub-classes to extend project-level maintenance functionality. - */ - protected function notifyProjects(Delete $queueForDeletes, int $usageStatsRetentionHourly): void - { - $queueForDeletes - ->setUsageRetentionHourlyDateTime(DateTime::addSeconds(new \DateTime(), -1 * $usageStatsRetentionHourly)) - ->trigger(); - } - protected function foreachProject(Database $dbForPlatform, callable $callback): void { // TODO: @Meldiron name of this method no longer matches. It does not delete, and it gives whole document diff --git a/src/Appwrite/Platform/Workers/Deletes.php b/src/Appwrite/Platform/Workers/Deletes.php index 539bbd61f9..dcfbd1d1e7 100644 --- a/src/Appwrite/Platform/Workers/Deletes.php +++ b/src/Appwrite/Platform/Workers/Deletes.php @@ -83,6 +83,9 @@ class Deletes extends Action $log->addTag('projectId', $project->getId()); $log->addTag('type', $type); + var_dump("--------------------------------"); + var_dump($type); + switch (\strval($type)) { case DELETE_TYPE_DOCUMENT: switch ($document->getCollection()) {