From 72e0ccf6d6fecd19b656fc0bd8333e540be2b7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Tue, 14 Mar 2023 19:39:40 +0100 Subject: [PATCH] Remove scheduleUpdatedAt --- app/config/collections.php | 11 ----------- app/controllers/api/functions.php | 25 +++++-------------------- app/workers/builds.php | 4 +--- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index ba44e846e2..5648bfe6ea 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -2311,17 +2311,6 @@ $collections = [ 'array' => false, 'filters' => [], ], - [ - '$id' => ID::custom('scheduleUpdatedAt'), - 'type' => Database::VAR_DATETIME, - 'format' => '', - 'size' => 0, - 'signed' => false, - 'required' => false, - 'default' => null, - 'array' => false, - 'filters' => ['datetime'], - ], [ '$id' => ID::custom('timeout'), 'type' => Database::VAR_INTEGER, diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 03734832f2..5c24b9bd06 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -86,7 +86,6 @@ App::post('/v1/functions') 'events' => $events, 'schedule' => $schedule, 'scheduleInternalId' => '', - 'scheduleUpdatedAt' => DateTime::now(), 'timeout' => $timeout, 'search' => implode(' ', [$functionId, $name, $runtime]) ])); @@ -416,7 +415,6 @@ App::put('/v1/functions/:functionId') 'name' => $name, 'events' => $events, 'schedule' => $schedule, - 'scheduleUpdatedAt' => DateTime::now(), 'timeout' => $timeout, 'enabled' => $enabled, 'search' => implode(' ', [$functionId, $name, $function->getAttribute('runtime')]), @@ -424,7 +422,7 @@ App::put('/v1/functions/:functionId') $schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId')); $schedule - ->setAttribute('resourceUpdatedAt', $function->getAttribute('scheduleUpdatedAt')) + ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); @@ -480,12 +478,11 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId') $function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [ 'deploymentInternalId' => $deployment->getInternalId(), 'deployment' => $deployment->getId(), - 'scheduleUpdatedAt' => DateTime::now() ]))); $schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId')); $schedule - ->setAttribute('resourceUpdatedAt', $function->getAttribute('scheduleUpdatedAt')) + ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); @@ -1347,13 +1344,9 @@ App::post('/v1/functions/:functionId/variables') $dbForProject->deleteCachedDocument('functions', $function->getId()); - $function = $dbForProject->getDocument('functions', $functionId); - $function->setAttribute('scheduleUpdatedAt', DateTime::now()); - $dbForProject->updateDocument('functions', $function->getId(), $function); - $schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId')); $schedule - ->setAttribute('resourceUpdatedAt', $function->getAttribute('scheduleUpdatedAt')) + ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); @@ -1475,13 +1468,9 @@ App::put('/v1/functions/:functionId/variables/:variableId') $dbForProject->deleteCachedDocument('functions', $function->getId()); - $function = $dbForProject->getDocument('functions', $functionId); - $function->setAttribute('scheduleUpdatedAt', DateTime::now()); - $dbForProject->updateDocument('functions', $function->getId(), $function); - $schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId')); $schedule - ->setAttribute('resourceUpdatedAt', $function->getAttribute('scheduleUpdatedAt')) + ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); @@ -1525,13 +1514,9 @@ App::delete('/v1/functions/:functionId/variables/:variableId') $dbForProject->deleteDocument('variables', $variable->getId()); $dbForProject->deleteCachedDocument('functions', $function->getId()); - $function = $dbForProject->getDocument('functions', $functionId); - $function->setAttribute('scheduleUpdatedAt', DateTime::now()); - $dbForProject->updateDocument('functions', $function->getId(), $function); - $schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId')); $schedule - ->setAttribute('resourceUpdatedAt', $function->getAttribute('scheduleUpdatedAt')) + ->setAttribute('resourceUpdatedAt', DateTime::now()) ->setAttribute('schedule', $function->getAttribute('schedule')) ->setAttribute('active', !empty($function->getAttribute('schedule')) && !empty($function->getAttribute('deployment'))); Authorization::skip(fn () => $dbForConsole->updateDocument('schedules', $schedule->getId(), $schedule)); diff --git a/app/workers/builds.php b/app/workers/builds.php index a2b29c0ab8..972eb5dd18 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -208,8 +208,6 @@ class BuildsV1 extends Worker Console::success("Build id: $buildId created"); - $function->setAttribute('scheduleUpdatedAt', DateTime::now()); - /** Set auto deploy */ if ($deployment->getAttribute('activate') === true) { $function->setAttribute('deploymentInternalId', $deployment->getInternalId()); @@ -220,7 +218,7 @@ class BuildsV1 extends Worker /** Update function schedule */ $dbForConsole = $this->getConsoleDB(); $schedule = $dbForConsole->getDocument('schedules', $function->getAttribute('scheduleId')); - $schedule->setAttribute('resourceUpdatedAt', $function->getAttribute('scheduleUpdatedAt')); + $schedule->setAttribute('resourceUpdatedAt', DateTime::now()); $schedule ->setAttribute('schedule', $function->getAttribute('schedule'))