From c449aa0a68d74ed09e99070fb9e11a7fff4c57e9 Mon Sep 17 00:00:00 2001 From: Khushboo Verma <43381712+vermakhushboo@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:15:45 +0530 Subject: [PATCH] Remove functions from installation response model --- app/controllers/api/vcs.php | 23 ------------------- .../Database/Validator/Queries/Functions.php | 3 ++- .../Utopia/Response/Model/Installation.php | 7 ------ 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/app/controllers/api/vcs.php b/app/controllers/api/vcs.php index ce6a633f28..270b440eda 100644 --- a/app/controllers/api/vcs.php +++ b/app/controllers/api/vcs.php @@ -766,7 +766,6 @@ App::get('/v1/vcs/installations') ->inject('dbForProject') ->inject('dbForConsole') ->action(function (array $queries, string $search, Response $response, Document $project, Database $dbForProject, Database $dbForConsole) { - $queries = Query::parseQueries($queries); $queries[] = Query::equal('projectInternalId', [$project->getInternalId()]); @@ -795,21 +794,6 @@ App::get('/v1/vcs/installations') $results = $dbForConsole->find('vcsInstallations', $queries); $total = $dbForConsole->count('vcsInstallations', $filterQueries, APP_LIMIT_COUNT); - if (\count($results) > 0) { - $installationIds = \array_map(fn ($result) => $result->getInternalId(), $results); - - $functions = Authorization::skip(fn () => $dbForProject->find('functions', [ - Query::equal('vcsInstallationInternalId', \array_unique($installationIds)), - Query::limit(APP_LIMIT_SUBQUERY) - ])); - - foreach ($results as $result) { - $installationFunctions = \array_filter($functions, fn ($function) => $function->getAttribute('vcsInstallationInternalId') === $result->getInternalId()); - - $result->setAttribute('functions', $installationFunctions); - } - } - $response->dynamic(new Document([ 'installations' => $results, 'total' => $total, @@ -843,13 +827,6 @@ App::get('/v1/vcs/installations/:installationId') throw new Exception(Exception::INSTALLATION_NOT_FOUND); } - $functions = Authorization::skip(fn () => $dbForProject->find('functions', [ - Query::equal('vcsInstallationInternalId', [$installation->getInternalId()]), - Query::limit(APP_LIMIT_SUBQUERY) - ])); - - $installation->setAttribute('functions', $functions); - $response->dynamic($installation, Response::MODEL_INSTALLATION); }); diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php b/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php index 9201e13604..2f62edbfb1 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Functions.php @@ -14,7 +14,8 @@ class Functions extends Base 'schedulePrevious', 'timeout', 'entrypoint', - 'commands' + 'commands', + 'vcsInstallationId' ]; /** diff --git a/src/Appwrite/Utopia/Response/Model/Installation.php b/src/Appwrite/Utopia/Response/Model/Installation.php index ceb0f51e72..842a91e514 100644 --- a/src/Appwrite/Utopia/Response/Model/Installation.php +++ b/src/Appwrite/Utopia/Response/Model/Installation.php @@ -47,13 +47,6 @@ class Installation extends Model 'description' => 'Provider installation ID.', 'default' => '', 'example' => '5322', - ]) - ->addRule('functions', [ - 'type' => Response::MODEL_FUNCTION, - 'description' => 'List of connected functions.', - 'default' => [], - 'example' => new \stdClass(), - 'array' => true, ]); }