From a93e8f3b0b03aa343975cef66e3701beea5922fd Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Tue, 25 Jan 2022 03:19:01 +0400 Subject: [PATCH] feat: update deletes,usage and functions worker --- app/tasks/usage.php | 2 +- app/workers/deletes.php | 8 ++++---- app/workers/functions.php | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/tasks/usage.php b/app/tasks/usage.php index e341dad3d8..cd2e6026f7 100644 --- a/app/tasks/usage.php +++ b/app/tasks/usage.php @@ -370,7 +370,7 @@ $cli // Get total storage $dbForProject->setNamespace('_project_' . $projectId); - $storageTotal = $dbForProject->sum('files', 'sizeOriginal') + $dbForProject->sum('tags', 'size'); + $storageTotal = $dbForProject->sum('files', 'sizeOriginal') + $dbForProject->sum('deployments', 'size'); $time = (int) (floor(time() / 1800) * 1800); // Time rounded to nearest 30 minutes $id = \md5($time . '_30m_storage.total'); //Construct unique id for each metric using time, period and metric diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 8caf7ddb23..bc7721d550 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -309,15 +309,15 @@ class DeletesV1 extends Worker $dbForProject = $this->getProjectDB($projectId); $device = new Local(APP_STORAGE_FUNCTIONS . '/app-' . $projectId); - // Delete Tags - $this->deleteByGroup('tags', [ + // Delete Deployments + $this->deleteByGroup('deployments', [ new Query('functionId', Query::TYPE_EQUAL, [$document->getId()]) ], $dbForProject, function (Document $document) use ($device) { if ($device->delete($document->getAttribute('path', ''))) { - Console::success('Delete code tag: ' . $document->getAttribute('path', '')); + Console::success('Delete code deployment: ' . $document->getAttribute('path', '')); } else { - Console::error('Failed to delete code tag: ' . $document->getAttribute('path', '')); + Console::error('Failed to delete code deployment: ' . $document->getAttribute('path', '')); } }); diff --git a/app/workers/functions.php b/app/workers/functions.php index 537e4ddd93..8dbaef42a4 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -126,11 +126,11 @@ class FunctionsV1 extends Worker foreach ($functions as $function) { $events = $function->getAttribute('events', []); - $tag = $function->getAttribute('tag', []); + $deployment = $function->getAttribute('deployment', []); Console::success('Itterating function: ' . $function->getAttribute('name')); - if (!\in_array($event, $events) || empty($tag)) { + if (!\in_array($event, $events) || empty($deployment)) { continue; } @@ -247,7 +247,7 @@ class FunctionsV1 extends Worker } /** - * Execute function tag + * Execute function deployment * * @param string $trigger * @param string $projectId