From a883d3728ff99db48c37957123b2bae3a704f533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 3 Oct 2022 07:16:49 +0000 Subject: [PATCH 1/2] Allow teamId queries on listProjects --- app/config/collections.php | 7 +++++++ composer.lock | 12 ++++++------ .../Utopia/Database/Validator/Queries/Projects.php | 3 ++- .../Services/Projects/ProjectsConsoleClientTest.php | 12 ++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 5b6e697f13..6f55516305 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -748,6 +748,13 @@ $collections = [ 'lengths' => [128], 'orders' => [Database::ORDER_ASC], ], + [ + '$id' => ID::custom('_key_team'), + 'type' => Database::INDEX_KEY, + 'attributes' => ['teamId'], + 'lengths' => [Database::LENGTH_KEY], + 'orders' => [Database::ORDER_ASC], + ], ], ], diff --git a/composer.lock b/composer.lock index 9ec0ea3197..7d676b49d5 100644 --- a/composer.lock +++ b/composer.lock @@ -5283,16 +5283,16 @@ }, { "name": "twig/twig", - "version": "v3.4.2", + "version": "v3.4.3", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "e07cdd3d430cd7e453c31b36eb5ad6c0c5e43077" + "reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/e07cdd3d430cd7e453c31b36eb5ad6c0c5e43077", - "reference": "e07cdd3d430cd7e453c31b36eb5ad6c0c5e43077", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/c38fd6b0b7f370c198db91ffd02e23b517426b58", + "reference": "c38fd6b0b7f370c198db91ffd02e23b517426b58", "shasum": "" }, "require": { @@ -5343,7 +5343,7 @@ ], "support": { "issues": "https://github.com/twigphp/Twig/issues", - "source": "https://github.com/twigphp/Twig/tree/v3.4.2" + "source": "https://github.com/twigphp/Twig/tree/v3.4.3" }, "funding": [ { @@ -5355,7 +5355,7 @@ "type": "tidelift" } ], - "time": "2022-08-12T06:47:24+00:00" + "time": "2022-09-28T08:42:51+00:00" } ], "aliases": [], diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php b/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php index cf2bea911a..7fff26db7f 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Projects.php @@ -7,7 +7,8 @@ use Appwrite\Utopia\Database\Validator\Queries\Base; class Projects extends Base { public const ALLOWED_ATTRIBUTES = [ - 'name' + 'name', + 'teamId' ]; /** diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 4c4d2e5213..2c80069433 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -167,6 +167,18 @@ class ProjectsConsoleClientTest extends Scope $this->assertArrayHasKey('webhooks', $response['body']); $this->assertArrayHasKey('keys', $response['body']); + $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'queries' => [ 'equal("teamId", "' . $team['body']['$id'] . '")' ], + ]); + + $this->assertEquals(200, $response['headers']['status-code']); + $this->assertNotEmpty($response['body']); + $this->assertCount(1, $response['body']['projects']); + $this->assertEquals($team['body']['$id'], $response['body']['projects'][0]['$id']); + $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], From a55b149d6f420dd6097704131ee059f9fb2e7b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Mon, 3 Oct 2022 07:54:55 +0000 Subject: [PATCH 2/2] Fix test --- tests/e2e/Services/Projects/ProjectsConsoleClientTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 2c80069433..592a09b4fc 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -177,7 +177,7 @@ class ProjectsConsoleClientTest extends Scope $this->assertEquals(200, $response['headers']['status-code']); $this->assertNotEmpty($response['body']); $this->assertCount(1, $response['body']['projects']); - $this->assertEquals($team['body']['$id'], $response['body']['projects'][0]['$id']); + $this->assertEquals($team['body']['$id'], $response['body']['projects'][0]['teamId']); $response = $this->client->call(Client::METHOD_GET, '/projects', array_merge([ 'content-type' => 'application/json',