diff --git a/.env b/.env index 1020440397..a12850dacb 100644 --- a/.env +++ b/.env @@ -84,7 +84,7 @@ _APP_LOGGING_CONFIG= _APP_GRAPHQL_MAX_BATCH_SIZE=10 _APP_GRAPHQL_MAX_COMPLEXITY=250 _APP_GRAPHQL_MAX_DEPTH=3 -_APP_SLOW_QUERIES_MAX_HITS=2 +_APP_SLOW_QUERIES_MAX_HITS=5 _APP_SLOW_QUERIES_TIMEOUT=1000 _APP_SLOW_QUERIES_BLOCK=enabled DOCKERHUB_PULL_USERNAME= diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index d15c4bb788..ea6f99a19f 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -204,7 +204,7 @@ App::error() ]))); } else { $document->setAttribute('count', $document->getAttribute('count') + 1); - $max = intval(App::getEnv('_APP_SLOW_QUERIES_MAX_HITS', 9999)); + $max = intval(App::getEnv('_APP_SLOW_QUERIES_MAX_HITS', 5)); if ($document->getAttribute('count') >= $max) { $document->setAttribute('blocked', true); } diff --git a/composer.lock b/composer.lock index d91e1f08d9..6c7393e215 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6122f6434efda86eca49811494128275", + "content-hash": "a6df2be9a59305de9a2f49acde473c60", "packages": [ { "name": "adhocore/jwt", @@ -2222,16 +2222,16 @@ }, { "name": "utopia-php/framework", - "version": "0.28.1", + "version": "0.27.0", "source": { "type": "git", "url": "https://github.com/utopia-php/framework.git", - "reference": "7f22c556fc5991e54e5811a68fb39809b21bda55" + "reference": "b8d0447f5c98291d7759db05460ecced29a0f9ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/framework/zipball/7f22c556fc5991e54e5811a68fb39809b21bda55", - "reference": "7f22c556fc5991e54e5811a68fb39809b21bda55", + "url": "https://api.github.com/repos/utopia-php/framework/zipball/b8d0447f5c98291d7759db05460ecced29a0f9ee", + "reference": "b8d0447f5c98291d7759db05460ecced29a0f9ee", "shasum": "" }, "require": { @@ -2260,9 +2260,9 @@ ], "support": { "issues": "https://github.com/utopia-php/framework/issues", - "source": "https://github.com/utopia-php/framework/tree/0.28.1" + "source": "https://github.com/utopia-php/framework/tree/0.27.0" }, - "time": "2023-03-02T08:16:01+00:00" + "time": "2023-01-29T05:36:17+00:00" }, { "name": "utopia-php/image", diff --git a/tests/e2e/Services/Databases/DatabasesBase.php b/tests/e2e/Services/Databases/DatabasesBase.php index ccef183762..e2f292111a 100644 --- a/tests/e2e/Services/Databases/DatabasesBase.php +++ b/tests/e2e/Services/Databases/DatabasesBase.php @@ -1049,7 +1049,7 @@ trait DatabasesBase } $docs = []; - for ($i = 0; $i <= 2; $i++) { + for ($i = 0; $i <= 5; $i++) { $docs[] = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/collections/' . $data['$id'] . '/documents', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -1060,6 +1060,9 @@ trait DatabasesBase } $this->assertEquals(408, $docs[0]['headers']['status-code']); // insert + $this->assertEquals(408, $docs[0]['headers']['status-code']); // update + $this->assertEquals(408, $docs[0]['headers']['status-code']); // update + $this->assertEquals(408, $docs[0]['headers']['status-code']); // update $this->assertEquals(403, $docs[1]['headers']['status-code']); // update $this->assertEquals(403, $docs[2]['headers']['status-code']); // blocked } diff --git a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php index e226d50d4e..ab83b3e0d0 100644 --- a/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php +++ b/tests/e2e/Services/Databases/DatabasesConsoleClientTest.php @@ -266,7 +266,7 @@ class DatabasesConsoleClientTest extends Scope } $docs = []; - for ($i = 0; $i <= 2; $i++) { + for ($i = 0; $i <= 5; $i++) { $docs[] = $this->client->call(Client::METHOD_GET, '/databases/' . $data['databaseId'] . '/collections/' . $data['$id'] . '/documents', array_merge([ 'content-type' => 'application/json', 'x-appwrite-project' => $this->getProject()['$id'], @@ -277,6 +277,9 @@ class DatabasesConsoleClientTest extends Scope } $this->assertEquals(408, $docs[0]['headers']['status-code']); // insert + $this->assertEquals(408, $docs[0]['headers']['status-code']); // update + $this->assertEquals(408, $docs[0]['headers']['status-code']); // update + $this->assertEquals(408, $docs[0]['headers']['status-code']); // update $this->assertEquals(403, $docs[1]['headers']['status-code']); // update $this->assertEquals(403, $docs[2]['headers']['status-code']); // blocked }