From 0522affba039d080e7f379eede636297e6f6cb09 Mon Sep 17 00:00:00 2001 From: fogelito Date: Tue, 15 Aug 2023 00:41:34 +0300 Subject: [PATCH] fix collections.php --- app/config/collections.php | 181 +++++++++--------- app/controllers/api/databases.php | 4 +- .../e2e/Services/Databases/DatabasesBase.php | 1 + 3 files changed, 94 insertions(+), 92 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index e0d3c7717a..cb765f699c 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1228,6 +1228,96 @@ $commonCollections = [ ], ], ], + + 'slowQueries' => [ + '$collection' => Database::METADATA, + '$id' => 'slowQueries', + 'name' => 'slowQueries', + 'attributes' => [ + [ + '$id' => ID::custom('blocked'), + 'type' => Database::VAR_BOOLEAN, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => true, + 'default' => false, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('count'), + 'type' => Database::VAR_INTEGER, + 'format' => '', + 'size' => 0, + 'signed' => true, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('queries'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 410002, + 'signed' => false, + 'required' => true, + 'default' => [], + 'array' => false, + 'filters' => ['json'], + ], + [ + '$id' => ID::custom('path'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 2500, + 'signed' => false, + 'required' => true, + 'default' => null, + 'array' => false, + 'filters' => [], + ], + [ + '$id' => ID::custom('databaseId'), + 'type' => Database::VAR_STRING, + 'signed' => true, + 'size' => Database::LENGTH_KEY, + 'format' => '', + 'filters' => [], + 'required' => true, + 'default' => null, + 'array' => false, + ], + [ + '$id' => ID::custom('collectionId'), + 'type' => Database::VAR_STRING, + 'signed' => true, + 'size' => Database::LENGTH_KEY, + 'format' => '', + 'filters' => [], + 'required' => true, + 'default' => null, + 'array' => false, + ], + ], + 'indexes' => [ + [ + '$id' => '_key_database_id', + 'type' => Database::INDEX_KEY, + 'attributes' => ['databaseId', 'collectionId'], + 'lengths' => [], + 'orders' => [] + ], + [ + '$id' => '_key_blocked', + 'type' => Database::INDEX_KEY, + 'attributes' => ['blocked', 'databaseId', 'collectionId'], + 'lengths' => [], + 'orders' => [] + ] + ], + ], ]; $projectCollections = array_merge([ @@ -3877,96 +3967,7 @@ $dbCollections = [ 'orders' => [Database::ORDER_ASC], ], ], - ], - 'slowQueries' => [ - '$collection' => Database::METADATA, - '$id' => 'slowQueries', - 'name' => 'slowQueries', - 'attributes' => [ - [ - '$id' => ID::custom('blocked'), - 'type' => Database::VAR_BOOLEAN, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => false, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('count'), - 'type' => Database::VAR_INTEGER, - 'format' => '', - 'size' => 0, - 'signed' => true, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('queries'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 410002, - 'signed' => false, - 'required' => true, - 'default' => [], - 'array' => false, - 'filters' => ['json'], - ], - [ - '$id' => ID::custom('path'), - 'type' => Database::VAR_STRING, - 'format' => '', - 'size' => 2500, - 'signed' => false, - 'required' => true, - 'default' => null, - 'array' => false, - 'filters' => [], - ], - [ - '$id' => ID::custom('databaseId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - [ - '$id' => ID::custom('collectionId'), - 'type' => Database::VAR_STRING, - 'signed' => true, - 'size' => Database::LENGTH_KEY, - 'format' => '', - 'filters' => [], - 'required' => true, - 'default' => null, - 'array' => false, - ], - ], - 'indexes' => [ - [ - '$id' => '_key_database_id', - 'type' => Database::INDEX_KEY, - 'attributes' => ['databaseId', 'collectionId'], - 'lengths' => [], - 'orders' => [] - ], - [ - '$id' => '_key_blocked', - 'type' => Database::INDEX_KEY, - 'attributes' => ['blocked', 'databaseId', 'collectionId'], - 'lengths' => [], - 'orders' => [] - ] - ], - ], + ] ]; diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 683af605c7..0e0bb24f99 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -2908,7 +2908,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') App::get('/v1/databases/:databaseId/collections/:collectionId/documents') ->alias('/v1/database/collections/:collectionId/documents', ['databaseId' => 'default']) ->desc('List Documents') - ->groups(['api', 'database','timeout']) + ->groups(['api', 'database', 'timeout']) ->label('scope', 'documents.read') ->label('sdk.auth', [APP_AUTH_TYPE_SESSION, APP_AUTH_TYPE_KEY, APP_AUTH_TYPE_JWT]) ->label('sdk.namespace', 'databases') @@ -2921,12 +2921,12 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') ->param('databaseId', '', new UID(), 'Database ID.') ->param('collectionId', '', new UID(), 'Collection ID. You can create a new collection using the Database service [server integration](https://appwrite.io/docs/server/databases#databasesCreateCollection).') ->param('queries', [], new ArrayList(new Text(APP_LIMIT_ARRAY_ELEMENT_SIZE), APP_LIMIT_ARRAY_PARAMS_SIZE), 'Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of ' . APP_LIMIT_ARRAY_PARAMS_SIZE . ' queries are allowed, each ' . APP_LIMIT_ARRAY_ELEMENT_SIZE . ' characters long.', true) + ->inject('request') ->inject('response') ->inject('dbForProject') ->inject('mode') ->action(function (string $databaseId, string $collectionId, array $queries, Request $request, Response $response, Database $dbForProject, string $mode) { - var_dump("inininininininni"); $database = Authorization::skip(fn() => $dbForProject->getDocument('databases', $databaseId)); if ($database->isEmpty() || (!$database->getAttribute('enabled') && $mode !== APP_MODE_ADMIN)) { diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index 81d7755cbb..57e59eb319 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -2,6 +2,7 @@ namespace Tests\E2E\Services\Databases; +use Appwrite\Extend\Exception; use Tests\E2E\Client; use Utopia\Database\Database; use Utopia\Database\DateTime;