diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index a00d485bec..1309eade74 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -1358,7 +1358,7 @@ App::get('/v1/account/logs') $queries = Query::parseQueries($queries); $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? 25; + $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; $audit = new EventAudit($dbForProject); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 76fcd9c0a3..7d5dd4046b 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -246,8 +246,8 @@ App::get('/v1/databases') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $databaseId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('databases', $databaseId); @@ -320,7 +320,7 @@ App::get('/v1/databases/:databaseId/logs') $queries = Query::parseQueries($queries); $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? 25; + $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; $audit = new Audit($dbForProject); @@ -566,8 +566,8 @@ App::get('/v1/databases/:databaseId/collections') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $collectionId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('database_' . $database->getInternalId(), $collectionId); @@ -659,7 +659,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') $queries = Query::parseQueries($queries); $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? 25; + $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; $audit = new Audit($dbForProject); @@ -1977,8 +1977,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents') $queries = Query::parseQueries($queries); // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $documentId = $cursor->getValue(); @@ -2121,7 +2121,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen $queries = Query::parseQueries($queries); $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? 25; + $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; $audit = new Audit($dbForProject); diff --git a/app/controllers/api/functions.php b/app/controllers/api/functions.php index 313e20967b..29a30ec54b 100644 --- a/app/controllers/api/functions.php +++ b/app/controllers/api/functions.php @@ -118,8 +118,8 @@ App::get('/v1/functions') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $functionId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('functions', $functionId); @@ -792,8 +792,8 @@ App::get('/v1/functions/:functionId/deployments') $queries[] = Query::equal('resourceType', ['functions']); // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $deploymentId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('deployments', $deploymentId); @@ -1145,8 +1145,8 @@ App::get('/v1/functions/:functionId/executions') $queries[] = Query::equal('functionId', [$function->getId()]); // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $executionId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('executions', $executionId); diff --git a/app/controllers/api/storage.php b/app/controllers/api/storage.php index 11fcb950f0..adada2f944 100644 --- a/app/controllers/api/storage.php +++ b/app/controllers/api/storage.php @@ -165,8 +165,8 @@ App::get('/v1/storage/buckets') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $bucketId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('buckets', $bucketId); @@ -676,8 +676,8 @@ App::get('/v1/storage/buckets/:bucketId/files') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $fileId = $cursor->getValue(); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 1811707aae..80f01d62fe 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -140,8 +140,8 @@ App::get('/v1/teams') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $teamId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('teams', $teamId); @@ -485,8 +485,8 @@ App::get('/v1/teams/:teamId/memberships') $queries[] = Query::equal('teamId', [$teamId]); // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $membershipId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('memberships', $membershipId); @@ -866,7 +866,7 @@ App::get('/v1/teams/:teamId/logs') $queries = Query::parseQueries($queries); $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? 25; + $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; $audit = new Audit($dbForProject); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 43373f954a..04af50ceb0 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -356,8 +356,8 @@ App::get('/v1/users') } // Get cursor document if there was a cursor query - $cursor = Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)[0] ?? null; - if ($cursor !== null) { + $cursor = reset(Query::getByType($queries, Query::TYPE_CURSORAFTER, Query::TYPE_CURSORBEFORE)); + if ($cursor) { /** @var Query $cursor */ $userId = $cursor->getValue(); $cursorDocument = $dbForProject->getDocument('users', $userId); @@ -541,7 +541,7 @@ App::get('/v1/users/:userId/logs') $queries = Query::parseQueries($queries); $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? 25; + $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; $audit = new Audit($dbForProject);