From a90b3eb307d88c600fc53c39e75c0f612b05ab8c Mon Sep 17 00:00:00 2001 From: fogelito Date: Mon, 13 Feb 2023 19:11:57 +0200 Subject: [PATCH] build after changes --- app/config/collections.php | 4 ++-- app/controllers/api/databases.php | 9 ++++++++- docker-compose.yml | 1 + 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/config/collections.php b/app/config/collections.php index 4697416cc9..14bee5b5c1 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -3624,8 +3624,8 @@ $collections = [ [ '$id' => '_key_database_id', 'type' => Database::INDEX_KEY, - 'attributes' => ['blocked'], - 'lengths' => [Database::LENGTH_KEY], + 'attributes' => ['databaseId', 'collectionId'], + 'lengths' => [], 'orders' => [] ], [ diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 8422390e9a..618986481c 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -202,7 +202,7 @@ App::error() /* @var $document Document */ $document = Authorization::skip(fn() => $dbForProject->getDocument('slow_queries', $key)); if ($document->isEmpty()) { - $document = Authorization::skip(fn()=>$dbForProject->createDocument('slow_queriesueries', new Document([ + $document = Authorization::skip(fn()=>$dbForProject->createDocument('slow_queries', new Document([ '$id' => $key, 'blocked' => false, 'count' => 1, @@ -214,6 +214,9 @@ App::error() } else { $document['count']++; $max = App::getEnv('_APP_SLOW_QUERIES_MAX_HITS', 99999); // todo: set default value + var_dump('_APP_SLOW_QUERIES_MAX_HITS'); + var_dump($max); + if ($document['count'] > $max) { $document['blocked'] = true; } @@ -2119,6 +2122,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') } $filterQueries = Query::groupByType($queries)['filters']; + + var_dump('_APP_SLOW_QUERIES_ACTIVE'); + var_dump(App::getEnv('_APP_SLOW_QUERIES_ACTIVE')); + $timeout = App::getEnv('_APP_SLOW_QUERIES_ACTIVE') === 'true' ? App::getEnv('_APP_SLOW_QUERIES_TIMEOUT') : null; if ($documentSecurity && !$valid) { diff --git a/docker-compose.yml b/docker-compose.yml index df1d5a78f3..b0bd567666 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -83,6 +83,7 @@ services: - ./docs:/usr/src/code/docs - ./public:/usr/src/code/public - ./src:/usr/src/code/src + - ./vendor/utopia-php/database:/usr/src/code/vendor/utopia-php/database depends_on: - mariadb - redis