From 449e8cc06c4037f38ab1561703a558934d81615c Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Thu, 11 Jan 2024 19:32:24 +1300 Subject: [PATCH] Fix function schedules --- src/Appwrite/Platform/Tasks/ScheduleFunctions.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php index 3128eb0538..e2c278714f 100644 --- a/src/Appwrite/Platform/Tasks/ScheduleFunctions.php +++ b/src/Appwrite/Platform/Tasks/ScheduleFunctions.php @@ -23,7 +23,7 @@ class ScheduleFunctions extends ScheduleBase public static function getSupportedResource(): string { - return 'message'; + return 'function'; } protected function enqueueResources(Group $pools, Database $dbForConsole): void @@ -73,11 +73,11 @@ class ScheduleFunctions extends ScheduleBase foreach ($scheduleKeys as $scheduleKey) { // Ensure schedule was not deleted - if (!isset($schedules[$scheduleKey])) { + if (!\array_key_exists($scheduleKey, $this->schedules)) { return; } - $schedule = $schedules[$scheduleKey]; + $schedule = $this->schedules[$scheduleKey]; $queueForFunctions = new Func($connection); @@ -95,7 +95,10 @@ class ScheduleFunctions extends ScheduleBase } $timerEnd = \microtime(true); - $this->lastEnqueueUpdate = $timerStart; + + // TODO: This was a bug before because it wasn't passed by reference, enabling it breaks scheduling + //$this->lastEnqueueUpdate = $timerStart; + Console::log("Enqueue tick: {$total} executions were enqueued in " . ($timerEnd - $timerStart) . " seconds"); } }