1
0
Fork 0
mirror of synced 2024-09-29 17:01:37 +13:00

Revert "Remove count, limit and offset limitations"

This reverts commit ae3535de0d.

# Conflicts:
#	composer.lock
This commit is contained in:
Jake Barnby 2023-02-28 16:42:21 +13:00
parent 04c1d3ca7f
commit 84f4813135
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
10 changed files with 60 additions and 74 deletions

View file

@ -1407,8 +1407,8 @@ App::get('/v1/account/logs')
$queries = Query::parseQueries($queries);
$grouped = Query::groupByType($queries);
$limit = $grouped['limit'] ?? null;
$offset = $grouped['offset'] ?? null;
$limit = $grouped['limit'] ?? APP_LIMIT_COUNT;
$offset = $grouped['offset'] ?? 0;
$audit = new EventAudit($dbForProject);

View file

@ -265,7 +265,7 @@ App::get('/v1/databases')
$response->dynamic(new Document([
'databases' => $dbForProject->find('databases', $queries),
'total' => $dbForProject->count('databases', $filterQueries),
'total' => $dbForProject->count('databases', $filterQueries, APP_LIMIT_COUNT),
]), Response::MODEL_DATABASE_LIST);
});
@ -322,8 +322,8 @@ App::get('/v1/databases/:databaseId/logs')
$queries = Query::parseQueries($queries);
$grouped = Query::groupByType($queries);
$limit = $grouped['limit'] ?? null;
$offset = $grouped['offset'] ?? null;
$limit = $grouped['limit'] ?? APP_LIMIT_COUNT;
$offset = $grouped['offset'] ?? 0;
$audit = new Audit($dbForProject);
$resource = 'database/' . $databaseId;
@ -590,7 +590,7 @@ App::get('/v1/databases/:databaseId/collections')
$response->dynamic(new Document([
'collections' => $dbForProject->find('database_' . $database->getInternalId(), $queries),
'total' => $dbForProject->count('database_' . $database->getInternalId(), $filterQueries),
'total' => $dbForProject->count('database_' . $database->getInternalId(), $filterQueries, APP_LIMIT_COUNT),
]), Response::MODEL_COLLECTION_LIST);
});
@ -666,8 +666,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs')
$queries = Query::parseQueries($queries);
$grouped = Query::groupByType($queries);
$limit = $grouped['limit'] ?? null;
$offset = $grouped['offset'] ?? null;
$limit = $grouped['limit'] ?? APP_LIMIT_COUNT;
$offset = $grouped['offset'] ?? 0;
$audit = new Audit($dbForProject);
$resource = 'database/' . $databaseId . '/collection/' . $collectionId;
@ -2036,10 +2036,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
if ($documentSecurity && !$valid) {
$documents = $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $queries);
$total = $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries);
$total = $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT);
} else {
$documents = Authorization::skip(fn () => $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $queries));
$total = Authorization::skip(fn () => $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries));
$total = Authorization::skip(fn () => $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT));
}
/**
@ -2163,8 +2163,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen
$queries = Query::parseQueries($queries);
$grouped = Query::groupByType($queries);
$limit = $grouped['limit'] ?? null;
$offset = $grouped['offset'] ?? null;
$limit = $grouped['limit'] ?? APP_LIMIT_COUNT;
$offset = $grouped['offset'] ?? 0;
$audit = new Audit($dbForProject);
$resource = 'database/' . $databaseId . '/collection/' . $collectionId . '/document/' . $document->getId();

View file

@ -156,7 +156,7 @@ App::get('/v1/functions')
$response->dynamic(new Document([
'functions' => $dbForProject->find('functions', $queries),
'total' => $dbForProject->count('functions', $filterQueries),
'total' => $dbForProject->count('functions', $filterQueries, APP_LIMIT_COUNT),
]), Response::MODEL_FUNCTION_LIST);
});
@ -831,7 +831,7 @@ App::get('/v1/functions/:functionId/deployments')
$filterQueries = Query::groupByType($queries)['filters'];
$results = $dbForProject->find('deployments', $queries);
$total = $dbForProject->count('deployments', $filterQueries);
$total = $dbForProject->count('deployments', $filterQueries, APP_LIMIT_COUNT);
foreach ($results as $result) {
$build = $dbForProject->getDocument('builds', $result->getAttribute('buildId', ''));
@ -1265,7 +1265,7 @@ App::get('/v1/functions/:functionId/executions')
$filterQueries = Query::groupByType($queries)['filters'];
$results = $dbForProject->find('executions', $queries);
$total = $dbForProject->count('executions', $filterQueries);
$total = $dbForProject->count('executions', $filterQueries, APP_LIMIT_COUNT);
$roles = Authorization::getRoles();
$isPrivilegedUser = Auth::isPrivilegedUser($roles);

View file

@ -215,7 +215,7 @@ App::get('/v1/projects')
$response->dynamic(new Document([
'projects' => $dbForConsole->find('projects', $queries),
'total' => $dbForConsole->count('projects', $filterQueries),
'total' => $dbForConsole->count('projects', $filterQueries, APP_LIMIT_COUNT),
]), Response::MODEL_PROJECT_LIST);
});
@ -726,6 +726,7 @@ App::get('/v1/projects/:projectId/webhooks')
$webhooks = $dbForConsole->find('webhooks', [
Query::equal('projectInternalId', [$project->getInternalId()]),
Query::limit(5000),
]);
$response->dynamic(new Document([
@ -973,6 +974,7 @@ App::get('/v1/projects/:projectId/keys')
$keys = $dbForConsole->find('keys', [
Query::equal('projectInternalId', [$project->getInternalId()]),
Query::limit(5000),
]);
$response->dynamic(new Document([
@ -1174,6 +1176,7 @@ App::get('/v1/projects/:projectId/platforms')
$platforms = $dbForConsole->find('platforms', [
Query::equal('projectId', [$project->getId()]),
Query::limit(5000),
]);
$response->dynamic(new Document([
@ -1391,6 +1394,7 @@ App::get('/v1/projects/:projectId/domains')
$domains = $dbForConsole->find('domains', [
Query::equal('projectInternalId', [$project->getInternalId()]),
Query::limit(5000),
]);
$response->dynamic(new Document([

View file

@ -185,7 +185,7 @@ App::get('/v1/storage/buckets')
$response->dynamic(new Document([
'buckets' => $dbForProject->find('buckets', $queries),
'total' => $dbForProject->count('buckets', $filterQueries),
'total' => $dbForProject->count('buckets', $filterQueries, APP_LIMIT_COUNT),
]), Response::MODEL_BUCKET_LIST);
});
@ -730,10 +730,10 @@ App::get('/v1/storage/buckets/:bucketId/files')
if ($fileSecurity && !$valid) {
$files = $dbForProject->find('bucket_' . $bucket->getInternalId(), $queries);
$total = $dbForProject->count('bucket_' . $bucket->getInternalId(), $filterQueries);
$total = $dbForProject->count('bucket_' . $bucket->getInternalId(), $filterQueries, APP_LIMIT_COUNT);
} else {
$files = Authorization::skip(fn () => $dbForProject->find('bucket_' . $bucket->getInternalId(), $queries));
$total = Authorization::skip(fn () => $dbForProject->count('bucket_' . $bucket->getInternalId(), $filterQueries));
$total = Authorization::skip(fn () => $dbForProject->count('bucket_' . $bucket->getInternalId(), $filterQueries, APP_LIMIT_COUNT));
}
$response->dynamic(new Document([

View file

@ -163,7 +163,7 @@ App::get('/v1/teams')
$filterQueries = Query::groupByType($queries)['filters'];
$results = $dbForProject->find('teams', $queries);
$total = $dbForProject->count('teams', $filterQueries);
$total = $dbForProject->count('teams', $filterQueries, APP_LIMIT_COUNT);
$response->dynamic(new Document([
'teams' => $results,
@ -542,7 +542,8 @@ App::get('/v1/teams/:teamId/memberships')
$total = $dbForProject->count(
collection: 'memberships',
queries: $filterQueries
queries: $filterQueries,
max: APP_LIMIT_COUNT
);
$memberships = array_filter($memberships, fn(Document $membership) => !empty($membership->getAttribute('userId')));
@ -904,8 +905,8 @@ App::get('/v1/teams/:teamId/logs')
$queries = Query::parseQueries($queries);
$grouped = Query::groupByType($queries);
$limit = $grouped['limit'] ?? null;
$offset = $grouped['offset'] ?? null;
$limit = $grouped['limit'] ?? APP_LIMIT_COUNT;
$offset = $grouped['offset'] ?? 0;
$audit = new Audit($dbForProject);
$resource = 'team/' . $team->getId();

View file

@ -390,7 +390,7 @@ App::get('/v1/users')
$response->dynamic(new Document([
'users' => $dbForProject->find('users', $queries),
'total' => $dbForProject->count('users', $filterQueries),
'total' => $dbForProject->count('users', $filterQueries, APP_LIMIT_COUNT),
]), Response::MODEL_USER_LIST);
});
@ -558,8 +558,8 @@ App::get('/v1/users/:userId/logs')
$queries = Query::parseQueries($queries);
$grouped = Query::groupByType($queries);
$limit = $grouped['limit'] ?? null;
$offset = $grouped['offset'] ?? null;
$limit = $grouped['limit'] ?? APP_LIMIT_COUNT;
$offset = $grouped['offset'] ?? 0;
$audit = new Audit($dbForProject);

View file

@ -84,6 +84,7 @@ const APP_USERAGENT = APP_NAME . '-Server v%s. Please report abuse at %s';
const APP_MODE_DEFAULT = 'default';
const APP_MODE_ADMIN = 'admin';
const APP_PAGING_LIMIT = 12;
const APP_LIMIT_COUNT = 5000;
const APP_LIMIT_USERS = 10000;
const APP_LIMIT_USER_SESSIONS_MAX = 100;
const APP_LIMIT_USER_SESSIONS_DEFAULT = 10;

View file

@ -43,13 +43,13 @@
"ext-sockets": "*",
"appwrite/php-clamav": "1.1.*",
"appwrite/php-runtimes": "0.11.*",
"utopia-php/abuse": "dev-feat-remove-limits as 0.18.0",
"utopia-php/abuse": "0.18.*",
"utopia-php/analytics": "0.2.*",
"utopia-php/audit": "dev-feat-remove-limits as 0.20.0",
"utopia-php/audit": "0.20.*",
"utopia-php/cache": "0.8.*",
"utopia-php/cli": "0.13.*",
"utopia-php/config": "0.2.*",
"utopia-php/database": "dev-refactor-limits as 0.30.1",
"utopia-php/database": "0.30.*",
"utopia-php/preloader": "0.2.*",
"utopia-php/domains": "1.1.*",
"utopia-php/framework": "0.26.*",

70
composer.lock generated
View file

@ -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": "3143c47027eeb7f880d909543cc66a48",
"content-hash": "ac80cafdd8c2c6deaec3dfe628084655",
"packages": [
{
"name": "adhocore/jwt",
@ -1808,28 +1808,29 @@
},
{
"name": "utopia-php/abuse",
"version": "dev-feat-remove-limits",
"version": "0.18.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/abuse.git",
"reference": "51dfdc53125eba3c377322976104a5eca45651b9"
"reference": "8496401234f73a49f8c4259d3e89ab4a7c1f9ecf"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/51dfdc53125eba3c377322976104a5eca45651b9",
"reference": "51dfdc53125eba3c377322976104a5eca45651b9",
"url": "https://api.github.com/repos/utopia-php/abuse/zipball/8496401234f73a49f8c4259d3e89ab4a7c1f9ecf",
"reference": "8496401234f73a49f8c4259d3e89ab4a7c1f9ecf",
"shasum": ""
},
"require": {
"ext-curl": "*",
"ext-pdo": "*",
"php": ">=8.0",
"utopia-php/database": "dev-refactor-limits as 0.30.1"
"utopia-php/database": "0.30.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
"phpstan/phpstan": "^1.9",
"phpunit/phpunit": "^9.4"
"phpstan/phpstan": "1.9.x-dev",
"phpunit/phpunit": "^9.4",
"vimeo/psalm": "4.0.1"
},
"type": "library",
"autoload": {
@ -1851,9 +1852,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/abuse/issues",
"source": "https://github.com/utopia-php/abuse/tree/feat-remove-limits"
"source": "https://github.com/utopia-php/abuse/tree/0.18.0"
},
"time": "2023-02-20T04:11:09+00:00"
"time": "2023-02-14T09:56:04+00:00"
},
{
"name": "utopia-php/analytics",
@ -1912,7 +1913,7 @@
},
{
"name": "utopia-php/audit",
"version": "dev-feat-remove-limits",
"version": "0.20.0",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/audit.git",
@ -1925,13 +1926,15 @@
"shasum": ""
},
"require": {
"ext-pdo": "*",
"php": ">=8.0",
"utopia-php/database": "dev-refactor-limits as 0.30.1"
"utopia-php/database": "0.30.*"
},
"require-dev": {
"laravel/pint": "1.2.*",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.3"
"phpunit/phpunit": "^9.3",
"vimeo/psalm": "4.0.1"
},
"type": "library",
"autoload": {
@ -1953,7 +1956,7 @@
],
"support": {
"issues": "https://github.com/utopia-php/audit/issues",
"source": "https://github.com/utopia-php/audit/tree/feat-remove-limits"
"source": "https://github.com/utopia-php/audit/tree/0.20.0"
},
"time": "2023-02-20T09:26:53+00:00"
},
@ -2112,16 +2115,16 @@
},
{
"name": "utopia-php/database",
"version": "dev-refactor-limits",
"version": "0.30.1",
"source": {
"type": "git",
"url": "https://github.com/utopia-php/database.git",
"reference": "d83a3e820c641ba0132c076172be9397df943a89"
"reference": "1cea72c1217357bf0747ae4f28ebef57e9dc0e65"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/utopia-php/database/zipball/d83a3e820c641ba0132c076172be9397df943a89",
"reference": "d83a3e820c641ba0132c076172be9397df943a89",
"url": "https://api.github.com/repos/utopia-php/database/zipball/1cea72c1217357bf0747ae4f28ebef57e9dc0e65",
"reference": "1cea72c1217357bf0747ae4f28ebef57e9dc0e65",
"shasum": ""
},
"require": {
@ -2160,9 +2163,9 @@
],
"support": {
"issues": "https://github.com/utopia-php/database/issues",
"source": "https://github.com/utopia-php/database/tree/refactor-limits"
"source": "https://github.com/utopia-php/database/tree/0.30.1"
},
"time": "2023-02-15T07:32:21+00:00"
"time": "2023-02-14T06:25:03+00:00"
},
{
"name": "utopia-php/domains",
@ -5561,32 +5564,9 @@
"time": "2023-02-08T07:49:20+00:00"
}
],
"aliases": [
{
"package": "utopia-php/abuse",
"version": "dev-feat-remove-limits",
"alias": "0.18.0",
"alias_normalized": "0.18.0.0"
},
{
"package": "utopia-php/audit",
"version": "dev-feat-remove-limits",
"alias": "0.20.0",
"alias_normalized": "0.20.0.0"
},
{
"package": "utopia-php/database",
"version": "dev-refactor-limits",
"alias": "0.30.1",
"alias_normalized": "0.30.1.0"
}
],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": {
"utopia-php/abuse": 20,
"utopia-php/audit": 20,
"utopia-php/database": 20
},
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {