From 06d22f910c8440beca129354cc0fe29cf4057bc2 Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 23 Feb 2025 20:51:38 +0200 Subject: [PATCH 01/17] disable logs display --- app/controllers/api/account.php | 6 ++++-- app/controllers/api/databases.php | 18 ++++++++++++------ app/controllers/api/messaging.php | 24 ++++++++++++++++-------- app/controllers/api/teams.php | 6 ++++-- app/controllers/api/users.php | 6 ++++-- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 21a04800b5..bef26ad25c 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2750,8 +2750,10 @@ App::get('/v1/account/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByUser($user->getInternalId()), - 'logs' => $output, + //'total' => $audit->countLogsByUser($user->getInternalId()), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index c563d1e8e0..3859132fd6 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -723,8 +723,10 @@ App::get('/v1/databases/:databaseId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -1112,8 +1114,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -3763,8 +3767,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index d7d3750ccf..06d49394aa 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -1047,8 +1047,10 @@ App::get('/v1/messaging/providers/:providerId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -2276,8 +2278,10 @@ App::get('/v1/messaging/topics/:topicId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -2686,8 +2690,10 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -3451,8 +3457,10 @@ App::get('/v1/messaging/messages/:messageId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 763aca64f0..7a9f21d74b 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1415,7 +1415,9 @@ App::get('/v1/teams/:teamId/logs') } } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 962022927f..ca3f042ba4 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -915,8 +915,10 @@ App::get('/v1/users/:userId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByUser($user->getInternalId()), - 'logs' => $output, + //'total' => $audit->countLogsByUser($user->getInternalId()), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); From 6bd14d548fbe36b7018a536b024c8eb20ca58fbb Mon Sep 17 00:00:00 2001 From: shimon Date: Sun, 23 Feb 2025 20:58:02 +0200 Subject: [PATCH 02/17] composer --- app/controllers/api/databases.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 3859132fd6..d9d62eac51 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -1115,7 +1115,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') $response->dynamic(new Document([ //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, + //'logs' => $output, 'total' => 0, 'logs' => [], ]), Response::MODEL_LOG_LIST); From 08f4ed2b50c96b827196a32c9de6fe8460afd68f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 15:50:10 +1300 Subject: [PATCH 03/17] Log batches per project --- src/Appwrite/Platform/Workers/Audits.php | 55 ++++++++++++++++-------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index f1ae46eea7..f645463aed 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -46,8 +46,9 @@ class Audits extends Action $this ->desc('Audits worker') ->inject('message') - ->inject('dbForProject') - ->callback(fn ($message, $dbForProject) => $this->action($message, $dbForProject)); + ->inject('getProjectDB') + ->inject('project') + ->callback([$this, 'action']); $this->lastTriggeredTime = time(); } @@ -55,14 +56,15 @@ class Audits extends Action /** * @param Message $message - * @param Database $dbForProject + * @param callable $getProjectDB + * @param Document $project * @return void * @throws Throwable * @throws \Utopia\Database\Exception * @throws Authorization * @throws Structure */ - public function action(Message $message, Database $dbForProject): void + public function action(Message $message, callable $getProjectDB, Document $project): void { $payload = $message->getPayload() ?? []; @@ -103,28 +105,43 @@ class Audits extends Action 'timestamp' => DateTime::formatTz(DateTime::now()) ]; - $this->logs[] = $eventData; + if (isset($this->logs[$project->getInternalId()])) { + $this->logs[$project->getInternalId()]['logs'][] = $eventData; + } else { + $this->logs[$project->getInternalId()] = [ + 'project' => new Document([ + '$id' => $project->getId(), + '$internalId' => $project->getInternalId(), + 'database' => $project->getAttribute('database'), + ]), + 'logs' => [$eventData] + ]; + } // Check if we should process the batch by checking both for the batch size and the elapsed time $batchSize = $this->getBatchSize(); - $shouldProcessBatch = count($this->logs) >= $batchSize; - if (!$shouldProcessBatch && count($this->logs) > 0) { - $shouldProcessBatch = (time() - $this->lastTriggeredTime) >= self::BATCH_AGGREGATION_INTERVAL; + $shouldProcessBatch = \count($this->logs) >= $batchSize; + if (!$shouldProcessBatch && \count($this->logs) > 0) { + $shouldProcessBatch = (\time() - $this->lastTriggeredTime) >= self::BATCH_AGGREGATION_INTERVAL; } if ($shouldProcessBatch) { - Console::log('Processing batch with ' . count($this->logs) . ' events'); - $audit = new Audit($dbForProject); + foreach ($this->logs as $projectLogs) { + $dbForProject = $getProjectDB($projectLogs['project']); - try { - $audit->logBatch($this->logs); - Console::success('Audit logs processed successfully'); - } catch (Throwable $e) { - Console::error('Error processing audit logs: ' . $e->getMessage()); - } finally { - // Clear the pending events after successful batch processing - $this->logs = []; - $this->lastTriggeredTime = time(); + Console::log('Processing batch with ' . count($projectLogs['logs']) . ' events'); + $audit = new Audit($dbForProject); + + try { + $audit->logBatch($projectLogs['logs']); + Console::success('Audit logs processed successfully'); + } catch (Throwable $e) { + Console::error('Error processing audit logs: ' . $e->getMessage()); + } finally { + // Clear the pending events after successful batch processing + $this->logs = []; + $this->lastTriggeredTime = time(); + } } } } From 3f8e1cbedbe98a9d381ae97d07399e30ebba387f Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 15:57:04 +1300 Subject: [PATCH 04/17] Fix loop unset --- composer.json | 8 +- composer.lock | 453 +++-------------------- src/Appwrite/Platform/Workers/Audits.php | 23 +- 3 files changed, 73 insertions(+), 411 deletions(-) diff --git a/composer.json b/composer.json index e182ac0fff..640faba78a 100644 --- a/composer.json +++ b/composer.json @@ -85,11 +85,11 @@ "require-dev": { "ext-fileinfo": "*", "appwrite/sdk-generator": "0.40.*", - "phpunit/phpunit": "9.5.20", + "phpunit/phpunit": "9.*", "swoole/ide-helper": "5.1.2", - "textalk/websocket": "1.5.7", - "laravel/pint": "^1.14", - "phpbench/phpbench": "^1.2" + "textalk/websocket": "1.5.*", + "laravel/pint": "1.*", + "phpbench/phpbench": "1.*" }, "provide": { "ext-phpiredis": "*" diff --git a/composer.lock b/composer.lock index 123ff3eade..ea2e425a12 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": "b1d26d441fe1fb6a26978d99ef01985f", + "content-hash": "ccd64a2bc1115b7f02225c8c06b24483", "packages": [ { "name": "adhocore/jwt", @@ -3919,16 +3919,16 @@ }, { "name": "utopia-php/framework", - "version": "0.33.16", + "version": "0.33.17", "source": { "type": "git", "url": "https://github.com/utopia-php/http.git", - "reference": "e91d4c560d1b809e25faa63d564fef034363b50f" + "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/http/zipball/e91d4c560d1b809e25faa63d564fef034363b50f", - "reference": "e91d4c560d1b809e25faa63d564fef034363b50f", + "url": "https://api.github.com/repos/utopia-php/http/zipball/73fac6fbce9f56282dba4e52a58cf836ec434644", + "reference": "73fac6fbce9f56282dba4e52a58cf836ec434644", "shasum": "" }, "require": { @@ -3960,9 +3960,9 @@ ], "support": { "issues": "https://github.com/utopia-php/http/issues", - "source": "https://github.com/utopia-php/http/tree/0.33.16" + "source": "https://github.com/utopia-php/http/tree/0.33.17" }, - "time": "2025-01-16T15:58:50+00:00" + "time": "2025-02-24T17:35:48+00:00" }, { "name": "utopia-php/image", @@ -5177,77 +5177,32 @@ }, "time": "2024-09-05T10:17:24+00:00" }, - { - "name": "doctrine/deprecations", - "version": "1.1.4", - "source": { - "type": "git", - "url": "https://github.com/doctrine/deprecations.git", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9", - "reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9", - "shasum": "" - }, - "require": { - "php": "^7.1 || ^8.0" - }, - "require-dev": { - "doctrine/coding-standard": "^9 || ^12", - "phpstan/phpstan": "1.4.10 || 2.0.3", - "phpstan/phpstan-phpunit": "^1.0 || ^2", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "psr/log": "^1 || ^2 || ^3" - }, - "suggest": { - "psr/log": "Allows logging deprecations via PSR-3 logger implementation" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Deprecations\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", - "homepage": "https://www.doctrine-project.org/", - "support": { - "issues": "https://github.com/doctrine/deprecations/issues", - "source": "https://github.com/doctrine/deprecations/tree/1.1.4" - }, - "time": "2024-12-07T21:18:45+00:00" - }, { "name": "doctrine/instantiator", - "version": "1.5.0", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/doctrine/instantiator.git", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b" + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/0a0fa9780f5d4e507415a065172d26a98d02047b", - "reference": "0a0fa9780f5d4e507415a065172d26a98d02047b", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", "shasum": "" }, "require": { - "php": "^7.1 || ^8.0" + "php": "^8.1" }, "require-dev": { - "doctrine/coding-standard": "^9 || ^11", + "doctrine/coding-standard": "^11", "ext-pdo": "*", "ext-phar": "*", - "phpbench/phpbench": "^0.16 || ^1", - "phpstan/phpstan": "^1.4", - "phpstan/phpstan-phpunit": "^1", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "vimeo/psalm": "^4.30 || ^5.4" + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" }, "type": "library", "autoload": { @@ -5274,7 +5229,7 @@ ], "support": { "issues": "https://github.com/doctrine/instantiator/issues", - "source": "https://github.com/doctrine/instantiator/tree/1.5.0" + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" }, "funding": [ { @@ -5290,7 +5245,7 @@ "type": "tidelift" } ], - "time": "2022-12-30T00:15:36+00:00" + "time": "2022-12-30T00:23:10+00:00" }, { "name": "doctrine/lexer", @@ -5944,298 +5899,6 @@ ], "time": "2025-01-26T19:54:45+00:00" }, - { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-2.x": "2.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" - }, - "time": "2020-06-27T09:03:43+00:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "5.6.1", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "reference": "e5e784149a09bd69d9a5e3b01c5cbd2e2bd653d8", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.1", - "ext-filter": "*", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7|^2.0", - "webmozart/assert": "^1.9.1" - }, - "require-dev": { - "mockery/mockery": "~1.3.5 || ~1.6.0", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.5", - "psalm/phar": "^5.26" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "5.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" - } - ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", - "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.6.1" - }, - "time": "2024-12-07T09:39:29+00:00" - }, - { - "name": "phpdocumentor/type-resolver", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "reference": "679e3ce485b99e84c775d28e2e96fade9a7fb50a", - "shasum": "" - }, - "require": { - "doctrine/deprecations": "^1.0", - "php": "^7.3 || ^8.0", - "phpdocumentor/reflection-common": "^2.0", - "phpstan/phpdoc-parser": "^1.18|^2.0" - }, - "require-dev": { - "ext-tokenizer": "*", - "phpbench/phpbench": "^1.2", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-phpunit": "^1.1", - "phpunit/phpunit": "^9.5", - "rector/rector": "^0.13.9", - "vimeo/psalm": "^4.25" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-1.x": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "phpDocumentor\\Reflection\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - } - ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", - "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.10.0" - }, - "time": "2024-11-09T15:12:26+00:00" - }, - { - "name": "phpspec/prophecy", - "version": "v1.20.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "a0165c648cab6a80311c74ffc708a07bb53ecc93" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/a0165c648cab6a80311c74ffc708a07bb53ecc93", - "reference": "a0165c648cab6a80311c74ffc708a07bb53ecc93", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.2 || ^2.0", - "php": "^7.2 || 8.0.* || 8.1.* || 8.2.* || 8.3.* || 8.4.*", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0 || ^5.0 || ^6.0", - "sebastian/recursion-context": "^3.0 || ^4.0 || ^5.0 || ^6.0" - }, - "require-dev": { - "friendsofphp/php-cs-fixer": "^3.40", - "phpspec/phpspec": "^6.0 || ^7.0", - "phpstan/phpstan": "^1.9", - "phpunit/phpunit": "^8.0 || ^9.0 || ^10.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Prophecy\\": "src/Prophecy" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "dev", - "fake", - "mock", - "spy", - "stub" - ], - "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.20.0" - }, - "time": "2024-11-19T13:12:41+00:00" - }, - { - "name": "phpstan/phpdoc-parser", - "version": "2.1.0", - "source": { - "type": "git", - "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", - "reference": "9b30d6fd026b2c132b3985ce6b23bec09ab3aa68", - "shasum": "" - }, - "require": { - "php": "^7.4 || ^8.0" - }, - "require-dev": { - "doctrine/annotations": "^2.0", - "nikic/php-parser": "^5.3.0", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^2.0", - "phpstan/phpstan-phpunit": "^2.0", - "phpstan/phpstan-strict-rules": "^2.0", - "phpunit/phpunit": "^9.6", - "symfony/process": "^5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "PHPStan\\PhpDocParser\\": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "PHPDoc parser with support for nullable, intersection and generic types", - "support": { - "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/2.1.0" - }, - "time": "2025-02-19T13:28:12+00:00" - }, { "name": "phpunit/php-code-coverage", "version": "9.2.32", @@ -6557,55 +6220,50 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.20", + "version": "9.6.22", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba" + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/12bc8879fb65aef2138b26fc633cb1e3620cffba", - "reference": "12bc8879fb65aef2138b26fc633cb1e3620cffba", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f80235cb4d3caa59ae09be3adf1ded27521d1a9c", + "reference": "f80235cb4d3caa59ae09be3adf1ded27521d1a9c", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.3.1", + "doctrine/instantiator": "^1.5.0 || ^2", "ext-dom": "*", "ext-json": "*", "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", "ext-xmlwriter": "*", - "myclabs/deep-copy": "^1.10.1", - "phar-io/manifest": "^2.0.3", - "phar-io/version": "^3.0.2", + "myclabs/deep-copy": "^1.12.1", + "phar-io/manifest": "^2.0.4", + "phar-io/version": "^3.2.1", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", - "phpunit/php-code-coverage": "^9.2.13", - "phpunit/php-file-iterator": "^3.0.5", + "phpunit/php-code-coverage": "^9.2.32", + "phpunit/php-file-iterator": "^3.0.6", "phpunit/php-invoker": "^3.1.1", - "phpunit/php-text-template": "^2.0.3", - "phpunit/php-timer": "^5.0.2", - "sebastian/cli-parser": "^1.0.1", - "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", - "sebastian/diff": "^4.0.3", - "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", - "sebastian/global-state": "^5.0.1", - "sebastian/object-enumerator": "^4.0.3", - "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", + "phpunit/php-text-template": "^2.0.4", + "phpunit/php-timer": "^5.0.3", + "sebastian/cli-parser": "^1.0.2", + "sebastian/code-unit": "^1.0.8", + "sebastian/comparator": "^4.0.8", + "sebastian/diff": "^4.0.6", + "sebastian/environment": "^5.1.5", + "sebastian/exporter": "^4.0.6", + "sebastian/global-state": "^5.0.7", + "sebastian/object-enumerator": "^4.0.4", + "sebastian/resource-operations": "^3.0.4", + "sebastian/type": "^3.2.1", "sebastian/version": "^3.0.2" }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { - "ext-soap": "*", - "ext-xdebug": "*" + "ext-soap": "To be able to generate mocks based on WSDL files", + "ext-xdebug": "PHP extension that provides line coverage as well as branch and path coverage" }, "bin": [ "phpunit" @@ -6613,7 +6271,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "9.5-dev" + "dev-master": "9.6-dev" } }, "autoload": { @@ -6644,7 +6302,8 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.20" + "security": "https://github.com/sebastianbergmann/phpunit/security/policy", + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.22" }, "funding": [ { @@ -6654,9 +6313,13 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" } ], - "time": "2022-04-01T12:37:26+00:00" + "time": "2024-12-05T13:48:26+00:00" }, { "name": "psr/cache", @@ -8520,16 +8183,16 @@ }, { "name": "textalk/websocket", - "version": "1.5.7", + "version": "1.5.8", "source": { "type": "git", "url": "https://github.com/Textalk/websocket-php.git", - "reference": "1712325e99b6bf869ccbf9bf41ab749e7328ea46" + "reference": "d05dbaa97500176447ffb1f1800573f23085ab13" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Textalk/websocket-php/zipball/1712325e99b6bf869ccbf9bf41ab749e7328ea46", - "reference": "1712325e99b6bf869ccbf9bf41ab749e7328ea46", + "url": "https://api.github.com/repos/Textalk/websocket-php/zipball/d05dbaa97500176447ffb1f1800573f23085ab13", + "reference": "d05dbaa97500176447ffb1f1800573f23085ab13", "shasum": "" }, "require": { @@ -8563,9 +8226,9 @@ "description": "WebSocket client and server", "support": { "issues": "https://github.com/Textalk/websocket-php/issues", - "source": "https://github.com/Textalk/websocket-php/tree/1.5.7" + "source": "https://github.com/Textalk/websocket-php/tree/1.5.8" }, - "time": "2022-03-29T09:46:59+00:00" + "time": "2022-04-26T06:28:24+00:00" }, { "name": "theseer/tokenizer", diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index f645463aed..977aff3cfb 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -7,7 +7,6 @@ use Exception; use Throwable; use Utopia\Audit\Audit; use Utopia\CLI\Console; -use Utopia\Database\Database; use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization; @@ -126,22 +125,22 @@ class Audits extends Action } if ($shouldProcessBatch) { - foreach ($this->logs as $projectLogs) { - $dbForProject = $getProjectDB($projectLogs['project']); + try { + foreach ($this->logs as $internalId => $projectLogs) { + $dbForProject = $getProjectDB($projectLogs['project']); - Console::log('Processing batch with ' . count($projectLogs['logs']) . ' events'); - $audit = new Audit($dbForProject); + Console::log('Processing batch with ' . count($projectLogs['logs']) . ' events'); + $audit = new Audit($dbForProject); - try { $audit->logBatch($projectLogs['logs']); Console::success('Audit logs processed successfully'); - } catch (Throwable $e) { - Console::error('Error processing audit logs: ' . $e->getMessage()); - } finally { - // Clear the pending events after successful batch processing - $this->logs = []; - $this->lastTriggeredTime = time(); + + unset($this->logs[$internalId]); } + } catch (Throwable $e) { + Console::error('Error processing audit logs: ' . $e->getMessage()); + } finally { + $this->lastTriggeredTime = time(); } } } From 5efd2318616db5622729ba318984373845f1ff18 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 16:56:13 +1300 Subject: [PATCH 05/17] Allow validator to read logs collections from base --- .../Utopia/Database/Validator/Queries/Base.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index af5d59ddfd..e64c55cf63 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -24,7 +24,15 @@ class Base extends Queries public function __construct(string $collection, array $allowedAttributes) { $config = Config::getParam('collections', []); - $collections = array_merge($config['projects'], $config['buckets'], $config['databases'], $config['console']); + + $collections = array_merge( + $config['projects'], + $config['buckets'], + $config['databases'], + $config['console'], + $config['log'] + ); + $collection = $collections[$collection]; // array for constant lookup time $allowedAttributesLookup = []; @@ -35,6 +43,7 @@ class Base extends Queries $attributes = []; foreach ($collection['attributes'] as $attribute) { $key = $attribute['$id']; + if (!isset($allowedAttributesLookup[$key])) { continue; } From 1f560d896fcd962e783a253d8eff9567487b2851 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 16:58:30 +1300 Subject: [PATCH 06/17] Fix plural --- src/Appwrite/Utopia/Database/Validator/Queries/Base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php index e64c55cf63..b8cff64214 100644 --- a/src/Appwrite/Utopia/Database/Validator/Queries/Base.php +++ b/src/Appwrite/Utopia/Database/Validator/Queries/Base.php @@ -30,7 +30,7 @@ class Base extends Queries $config['buckets'], $config['databases'], $config['console'], - $config['log'] + $config['logs'] ); $collection = $collections[$collection]; From 6f854b5eb6ba084ca6dc3aef819fe0b9c685376a Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 18:18:25 +1300 Subject: [PATCH 07/17] Remove blocks --- app/controllers/api/account.php | 6 ++---- app/controllers/api/databases.php | 18 ++++++------------ app/controllers/api/messaging.php | 24 ++++++++---------------- app/controllers/api/teams.php | 6 ++---- app/controllers/api/users.php | 6 ++---- 5 files changed, 20 insertions(+), 40 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index bef26ad25c..21a04800b5 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2750,10 +2750,8 @@ App::get('/v1/account/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByUser($user->getInternalId()), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByUser($user->getInternalId()), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index d9d62eac51..c563d1e8e0 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -723,10 +723,8 @@ App::get('/v1/databases/:databaseId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -1114,10 +1112,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -3767,10 +3763,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 06d49394aa..d7d3750ccf 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -1047,10 +1047,8 @@ App::get('/v1/messaging/providers/:providerId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -2278,10 +2276,8 @@ App::get('/v1/messaging/topics/:topicId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -2690,10 +2686,8 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -3457,10 +3451,8 @@ App::get('/v1/messaging/messages/:messageId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 7a9f21d74b..763aca64f0 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1415,9 +1415,7 @@ App::get('/v1/teams/:teamId/logs') } } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index ca3f042ba4..962022927f 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -915,10 +915,8 @@ App::get('/v1/users/:userId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByUser($user->getInternalId()), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByUser($user->getInternalId()), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); From f49346485ad303e5a8b989d5519feeb62f509952 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 18:39:12 +1300 Subject: [PATCH 08/17] Revert "Remove blocks" This reverts commit 6f854b5eb6ba084ca6dc3aef819fe0b9c685376a. --- app/controllers/api/account.php | 6 ++++-- app/controllers/api/databases.php | 18 ++++++++++++------ app/controllers/api/messaging.php | 24 ++++++++++++++++-------- app/controllers/api/teams.php | 6 ++++-- app/controllers/api/users.php | 6 ++++-- 5 files changed, 40 insertions(+), 20 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 21a04800b5..bef26ad25c 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2750,8 +2750,10 @@ App::get('/v1/account/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByUser($user->getInternalId()), - 'logs' => $output, + //'total' => $audit->countLogsByUser($user->getInternalId()), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index c563d1e8e0..d9d62eac51 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -723,8 +723,10 @@ App::get('/v1/databases/:databaseId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -1112,8 +1114,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -3763,8 +3767,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index d7d3750ccf..06d49394aa 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -1047,8 +1047,10 @@ App::get('/v1/messaging/providers/:providerId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -2276,8 +2278,10 @@ App::get('/v1/messaging/topics/:topicId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -2686,8 +2690,10 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); @@ -3451,8 +3457,10 @@ App::get('/v1/messaging/messages/:messageId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 763aca64f0..7a9f21d74b 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1415,7 +1415,9 @@ App::get('/v1/teams/:teamId/logs') } } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), - 'logs' => $output, + //'total' => $audit->countLogsByResource($resource), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 962022927f..ca3f042ba4 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -915,8 +915,10 @@ App::get('/v1/users/:userId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByUser($user->getInternalId()), - 'logs' => $output, + //'total' => $audit->countLogsByUser($user->getInternalId()), + //'logs' => $output, + 'total' => 0, + 'logs' => [], ]), Response::MODEL_LOG_LIST); }); From b0547015a976a12f11275878e51335c94f99c9a1 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 18:51:11 +1300 Subject: [PATCH 09/17] Add temp log date skip --- app/controllers/api/account.php | 4 ++++ app/controllers/api/databases.php | 20 +++++++++++++++++++- app/controllers/api/messaging.php | 16 ++++++++++++++++ app/controllers/api/teams.php | 4 ++++ app/controllers/api/users.php | 4 ++++ 5 files changed, 47 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index bef26ad25c..e96df1fa4f 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2715,6 +2715,10 @@ App::get('/v1/account/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index d9d62eac51..b6c3af4a52 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -23,6 +23,7 @@ use Utopia\App; use Utopia\Audit\Audit; use Utopia\Config\Config; use Utopia\Database\Database; +use Utopia\Database\DateTime; use Utopia\Database\Document; use Utopia\Database\Exception\Authorization as AuthorizationException; use Utopia\Database\Exception\Conflict as ConflictException; @@ -669,6 +670,10 @@ App::get('/v1/databases/:databaseId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; @@ -1059,7 +1064,16 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') throw new Exception(Exception::COLLECTION_NOT_FOUND); } - $queries = Query::parseQueries($queries); + try { + $queries = Query::parseQueries($queries); + } catch (QueryException $e) { + throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); + } + + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; @@ -3713,6 +3727,10 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 06d49394aa..53257a62c9 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -994,6 +994,10 @@ App::get('/v1/messaging/providers/:providerId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; @@ -2224,6 +2228,10 @@ App::get('/v1/messaging/topics/:topicId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; @@ -2636,6 +2644,10 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; @@ -3403,6 +3415,10 @@ App::get('/v1/messaging/messages/:messageId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 7a9f21d74b..cde4171550 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1362,6 +1362,10 @@ App::get('/v1/teams/:teamId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index ca3f042ba4..021ae6554a 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -862,6 +862,10 @@ App::get('/v1/users/:userId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } + // Temp fix for logs, remove after 1 log cycle + $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); + $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + $grouped = Query::groupByType($queries); $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; $offset = $grouped['offset'] ?? 0; From 2924f408b320ef8eec18a5b242d23e9364948dc6 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 19:21:35 +1300 Subject: [PATCH 10/17] Reapply "Remove blocks" This reverts commit f49346485ad303e5a8b989d5519feeb62f509952. --- app/controllers/api/account.php | 6 ++---- app/controllers/api/databases.php | 18 ++++++------------ app/controllers/api/messaging.php | 24 ++++++++---------------- app/controllers/api/teams.php | 6 ++---- app/controllers/api/users.php | 6 ++---- 5 files changed, 20 insertions(+), 40 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index e96df1fa4f..dcf5d5c3ab 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2754,10 +2754,8 @@ App::get('/v1/account/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByUser($user->getInternalId()), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByUser($user->getInternalId()), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index b6c3af4a52..9d93ba52a9 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -728,10 +728,8 @@ App::get('/v1/databases/:databaseId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -1128,10 +1126,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -3785,10 +3781,8 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 53257a62c9..2960008cd0 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -1051,10 +1051,8 @@ App::get('/v1/messaging/providers/:providerId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -2286,10 +2284,8 @@ App::get('/v1/messaging/topics/:topicId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -2702,10 +2698,8 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -3473,10 +3467,8 @@ App::get('/v1/messaging/messages/:messageId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index cde4171550..6df62eccb2 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1419,9 +1419,7 @@ App::get('/v1/teams/:teamId/logs') } } $response->dynamic(new Document([ - //'total' => $audit->countLogsByResource($resource), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByResource($resource), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 021ae6554a..6b39d12d42 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -919,10 +919,8 @@ App::get('/v1/users/:userId/logs') } $response->dynamic(new Document([ - //'total' => $audit->countLogsByUser($user->getInternalId()), - //'logs' => $output, - 'total' => 0, - 'logs' => [], + 'total' => $audit->countLogsByUser($user->getInternalId()), + 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); From b272a8b1e711210c699d2261e35d75acd34f6d14 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 20:26:00 +1300 Subject: [PATCH 11/17] Pass queries --- app/controllers/api/account.php | 8 ++--- app/controllers/api/databases.php | 24 ++++--------- app/controllers/api/messaging.php | 32 +++++------------- app/controllers/api/teams.php | 8 ++--- app/controllers/api/users.php | 8 ++--- composer.json | 6 ++-- composer.lock | 56 +++++++++++++++---------------- 7 files changed, 51 insertions(+), 91 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index dcf5d5c3ab..e670c68bc4 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2719,13 +2719,9 @@ App::get('/v1/account/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new EventAudit($dbForProject); - $logs = $audit->getLogsByUser($user->getInternalId(), $limit, $offset); + $logs = $audit->getLogsByUser($user->getInternalId(), $queries); $output = []; @@ -2754,7 +2750,7 @@ App::get('/v1/account/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByUser($user->getInternalId()), + 'total' => $audit->countLogsByUser($user->getInternalId(), $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 9d93ba52a9..8980300aef 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -674,13 +674,9 @@ App::get('/v1/databases/:databaseId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'database/' . $databaseId; - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -728,7 +724,7 @@ App::get('/v1/databases/:databaseId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -1072,13 +1068,9 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'database/' . $databaseId . '/collection/' . $collectionId; - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -1126,7 +1118,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -3727,13 +3719,9 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'database/' . $databaseId . '/collection/' . $collectionId . '/document/' . $document->getId(); - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -3781,7 +3769,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 2960008cd0..1c9efb6193 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -998,13 +998,9 @@ App::get('/v1/messaging/providers/:providerId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'provider/' . $providerId; - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; foreach ($logs as $i => &$log) { @@ -1051,7 +1047,7 @@ App::get('/v1/messaging/providers/:providerId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -2230,13 +2226,9 @@ App::get('/v1/messaging/topics/:topicId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'topic/' . $topicId; - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -2284,7 +2276,7 @@ App::get('/v1/messaging/topics/:topicId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -2644,13 +2636,9 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'subscriber/' . $subscriberId; - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -2698,7 +2686,7 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); @@ -3413,13 +3401,9 @@ App::get('/v1/messaging/messages/:messageId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'message/' . $messageId; - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -3467,7 +3451,7 @@ App::get('/v1/messaging/messages/:messageId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 6df62eccb2..9defb9b013 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1366,13 +1366,9 @@ App::get('/v1/teams/:teamId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); $resource = 'team/' . $team->getId(); - $logs = $audit->getLogsByResource($resource, $limit, $offset); + $logs = $audit->getLogsByResource($resource, $queries); $output = []; @@ -1419,7 +1415,7 @@ App::get('/v1/teams/:teamId/logs') } } $response->dynamic(new Document([ - 'total' => $audit->countLogsByResource($resource), + 'total' => $audit->countLogsByResource($resource, $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 6b39d12d42..aab41991f3 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -866,13 +866,9 @@ App::get('/v1/users/:userId/logs') $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); - $grouped = Query::groupByType($queries); - $limit = $grouped['limit'] ?? APP_LIMIT_COUNT; - $offset = $grouped['offset'] ?? 0; - $audit = new Audit($dbForProject); - $logs = $audit->getLogsByUser($user->getInternalId(), $limit, $offset); + $logs = $audit->getLogsByUser($user->getInternalId(), $queries); $output = []; @@ -919,7 +915,7 @@ App::get('/v1/users/:userId/logs') } $response->dynamic(new Document([ - 'total' => $audit->countLogsByUser($user->getInternalId()), + 'total' => $audit->countLogsByUser($user->getInternalId(), $queries), 'logs' => $output, ]), Response::MODEL_LOG_LIST); }); diff --git a/composer.json b/composer.json index 640faba78a..6180773b24 100644 --- a/composer.json +++ b/composer.json @@ -45,13 +45,13 @@ "ext-sockets": "*", "appwrite/php-runtimes": "0.16.*", "appwrite/php-clamav": "2.0.*", - "utopia-php/abuse": "0.50.*", + "utopia-php/abuse": "0.51.*", "utopia-php/analytics": "0.10.*", - "utopia-php/audit": "0.51.*", + "utopia-php/audit": "0.54.0", "utopia-php/cache": "0.11.*", "utopia-php/cli": "0.15.*", "utopia-php/config": "0.2.*", - "utopia-php/database": "0.59.0", + "utopia-php/database": "0.60.*", "utopia-php/domains": "0.5.*", "utopia-php/dsn": "0.2.1", "utopia-php/framework": "0.33.*", diff --git a/composer.lock b/composer.lock index ea2e425a12..841d5b51c5 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": "ccd64a2bc1115b7f02225c8c06b24483", + "content-hash": "87a12bb6f58c5dad7488229590e9a3f5", "packages": [ { "name": "adhocore/jwt", @@ -3377,16 +3377,16 @@ }, { "name": "utopia-php/abuse", - "version": "0.50.0", + "version": "0.51.0", "source": { "type": "git", "url": "https://github.com/utopia-php/abuse.git", - "reference": "3ff67819e9de61506c5ca070a70552f7ebe99f80" + "reference": "661687b03277f1d202a0e8cf9da6e58c97da2b5e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/abuse/zipball/3ff67819e9de61506c5ca070a70552f7ebe99f80", - "reference": "3ff67819e9de61506c5ca070a70552f7ebe99f80", + "url": "https://api.github.com/repos/utopia-php/abuse/zipball/661687b03277f1d202a0e8cf9da6e58c97da2b5e", + "reference": "661687b03277f1d202a0e8cf9da6e58c97da2b5e", "shasum": "" }, "require": { @@ -3394,7 +3394,7 @@ "ext-pdo": "*", "ext-redis": "*", "php": ">=8.0", - "utopia-php/database": "0.59.*" + "utopia-php/database": "0.60.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3422,9 +3422,9 @@ ], "support": { "issues": "https://github.com/utopia-php/abuse/issues", - "source": "https://github.com/utopia-php/abuse/tree/0.50.0" + "source": "https://github.com/utopia-php/abuse/tree/0.51.0" }, - "time": "2025-02-12T09:13:59+00:00" + "time": "2025-02-17T11:10:18+00:00" }, { "name": "utopia-php/analytics", @@ -3474,21 +3474,21 @@ }, { "name": "utopia-php/audit", - "version": "0.51.0", + "version": "0.54.0", "source": { "type": "git", "url": "https://github.com/utopia-php/audit.git", - "reference": "a5a4b73a57e27a0fac8025b1d6038e145a1ca04e" + "reference": "1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/audit/zipball/a5a4b73a57e27a0fac8025b1d6038e145a1ca04e", - "reference": "a5a4b73a57e27a0fac8025b1d6038e145a1ca04e", + "url": "https://api.github.com/repos/utopia-php/audit/zipball/1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975", + "reference": "1b0cb8ac6bfbd7703e3f9a753c6ba59ff1c39975", "shasum": "" }, "require": { "php": ">=8.0", - "utopia-php/database": "0.59.*" + "utopia-php/database": "0.60.*" }, "require-dev": { "laravel/pint": "1.*", @@ -3515,9 +3515,9 @@ ], "support": { "issues": "https://github.com/utopia-php/audit/issues", - "source": "https://github.com/utopia-php/audit/tree/0.51.0" + "source": "https://github.com/utopia-php/audit/tree/0.54.0" }, - "time": "2025-02-12T09:12:44+00:00" + "time": "2025-02-25T07:21:07+00:00" }, { "name": "utopia-php/cache", @@ -3717,16 +3717,16 @@ }, { "name": "utopia-php/database", - "version": "0.59.0", + "version": "0.60.3", "source": { "type": "git", "url": "https://github.com/utopia-php/database.git", - "reference": "0eed7f1ad3eb66ff4a7d73b68dd9d3e05089eb18" + "reference": "c4bc4af3f09a91aea76aac75b4b78fa06598c61d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/database/zipball/0eed7f1ad3eb66ff4a7d73b68dd9d3e05089eb18", - "reference": "0eed7f1ad3eb66ff4a7d73b68dd9d3e05089eb18", + "url": "https://api.github.com/repos/utopia-php/database/zipball/c4bc4af3f09a91aea76aac75b4b78fa06598c61d", + "reference": "c4bc4af3f09a91aea76aac75b4b78fa06598c61d", "shasum": "" }, "require": { @@ -3767,9 +3767,9 @@ ], "support": { "issues": "https://github.com/utopia-php/database/issues", - "source": "https://github.com/utopia-php/database/tree/0.59.0" + "source": "https://github.com/utopia-php/database/tree/0.60.3" }, - "time": "2025-02-12T08:08:29+00:00" + "time": "2025-02-17T12:46:59+00:00" }, { "name": "utopia-php/domains", @@ -4171,16 +4171,16 @@ }, { "name": "utopia-php/migration", - "version": "0.6.19", + "version": "0.6.20", "source": { "type": "git", "url": "https://github.com/utopia-php/migration.git", - "reference": "3c9497f7a54ef88b1077c48d8326893133ad78eb" + "reference": "8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/migration/zipball/3c9497f7a54ef88b1077c48d8326893133ad78eb", - "reference": "3c9497f7a54ef88b1077c48d8326893133ad78eb", + "url": "https://api.github.com/repos/utopia-php/migration/zipball/8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba", + "reference": "8c9ba52196f50aaef4aa1903f0d8fe0c8d9997ba", "shasum": "" }, "require": { @@ -4188,7 +4188,7 @@ "ext-curl": "*", "ext-openssl": "*", "php": ">=8.1", - "utopia-php/database": "0.59.*", + "utopia-php/database": "0.60.*", "utopia-php/dsn": "0.2.*", "utopia-php/framework": "0.33.*", "utopia-php/storage": "0.18.*" @@ -4221,9 +4221,9 @@ ], "support": { "issues": "https://github.com/utopia-php/migration/issues", - "source": "https://github.com/utopia-php/migration/tree/0.6.19" + "source": "https://github.com/utopia-php/migration/tree/0.6.20" }, - "time": "2025-02-13T07:50:21+00:00" + "time": "2025-02-17T11:02:15+00:00" }, { "name": "utopia-php/mongo", From 03f0e382f4192ed75cbe9f4bb0f27ad561dd30ed Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 21:03:37 +1300 Subject: [PATCH 12/17] Fix dates --- app/controllers/api/account.php | 8 +++-- app/controllers/api/databases.php | 24 ++++++++------ app/controllers/api/messaging.php | 32 ++++++++++++------- app/controllers/api/teams.php | 8 +++-- app/controllers/api/users.php | 8 +++-- .../Account/AccountCustomClientTest.php | 1 + 6 files changed, 51 insertions(+), 30 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index e670c68bc4..438a036274 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2715,9 +2715,11 @@ App::get('/v1/account/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new EventAudit($dbForProject); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 8980300aef..3cc9c110c0 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -670,9 +670,11 @@ App::get('/v1/databases/:databaseId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'database/' . $databaseId; @@ -1064,9 +1066,11 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'database/' . $databaseId . '/collection/' . $collectionId; @@ -3715,9 +3719,11 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'database/' . $databaseId . '/collection/' . $collectionId . '/document/' . $document->getId(); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 1c9efb6193..2e89863ec3 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -994,9 +994,11 @@ App::get('/v1/messaging/providers/:providerId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'provider/' . $providerId; @@ -2222,9 +2224,11 @@ App::get('/v1/messaging/topics/:topicId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'topic/' . $topicId; @@ -2632,9 +2636,11 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'subscriber/' . $subscriberId; @@ -3397,9 +3403,11 @@ App::get('/v1/messaging/messages/:messageId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'message/' . $messageId; diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 9defb9b013..815bd6db1d 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1362,9 +1362,11 @@ App::get('/v1/teams/:teamId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); $resource = 'team/' . $team->getId(); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index aab41991f3..5e58a610cf 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -862,9 +862,11 @@ App::get('/v1/users/:userId/logs') throw new Exception(Exception::GENERAL_QUERY_INVALID, $e->getMessage()); } - // Temp fix for logs, remove after 1 log cycle - $queries[] = Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-126T00:00+0'))); - $queries[] = Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+0'))); + // Temp fix for logs + $queries[] = Query::or([ + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), + ]); $audit = new Audit($dbForProject); diff --git a/tests/e2e/Services/Account/AccountCustomClientTest.php b/tests/e2e/Services/Account/AccountCustomClientTest.php index 788f949fb3..439fa24fb6 100644 --- a/tests/e2e/Services/Account/AccountCustomClientTest.php +++ b/tests/e2e/Services/Account/AccountCustomClientTest.php @@ -277,6 +277,7 @@ class AccountCustomClientTest extends Scope { sleep(5); $session = $data['session'] ?? ''; + /** * Test for SUCCESS */ From 3a2babc906f0ca2a65a70ae42b4620907b2805e3 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Tue, 25 Feb 2025 21:34:46 +1300 Subject: [PATCH 13/17] Update date --- app/controllers/api/account.php | 2 +- app/controllers/api/databases.php | 6 +++--- app/controllers/api/messaging.php | 8 ++++---- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 438a036274..1ba3204134 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2717,7 +2717,7 @@ App::get('/v1/account/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index 3cc9c110c0..ffe9142251 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -672,7 +672,7 @@ App::get('/v1/databases/:databaseId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -1068,7 +1068,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -3721,7 +3721,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 2e89863ec3..05bb461faf 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -996,7 +996,7 @@ App::get('/v1/messaging/providers/:providerId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -2226,7 +2226,7 @@ App::get('/v1/messaging/topics/:topicId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -2638,7 +2638,7 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -3405,7 +3405,7 @@ App::get('/v1/messaging/messages/:messageId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 815bd6db1d..5fbc1a4e08 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1364,7 +1364,7 @@ App::get('/v1/teams/:teamId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 5e58a610cf..0bea1a07f9 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -864,7 +864,7 @@ App::get('/v1/users/:userId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T00:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); From 7dfa3193c933e33b04011a0aad8f2b5565ae448b Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 26 Feb 2025 13:45:49 +1300 Subject: [PATCH 14/17] Test increase batch --- src/Appwrite/Platform/Workers/Audits.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index 977aff3cfb..becc6f0d4e 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -17,7 +17,7 @@ use Utopia\System\System; class Audits extends Action { - private const BATCH_SIZE_DEVELOPMENT = 1; // smaller batch size for development + private const BATCH_SIZE_DEVELOPMENT = 3; // smaller batch size for development private const BATCH_SIZE_PRODUCTION = 5_000; private const BATCH_AGGREGATION_INTERVAL = 60; // in seconds From 34d91a6518fd5c37203e7c57328e7b9091ede14e Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 26 Feb 2025 13:51:41 +1300 Subject: [PATCH 15/17] Revert "Test increase batch" This reverts commit 7dfa3193c933e33b04011a0aad8f2b5565ae448b. --- src/Appwrite/Platform/Workers/Audits.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/Audits.php b/src/Appwrite/Platform/Workers/Audits.php index becc6f0d4e..977aff3cfb 100644 --- a/src/Appwrite/Platform/Workers/Audits.php +++ b/src/Appwrite/Platform/Workers/Audits.php @@ -17,7 +17,7 @@ use Utopia\System\System; class Audits extends Action { - private const BATCH_SIZE_DEVELOPMENT = 3; // smaller batch size for development + private const BATCH_SIZE_DEVELOPMENT = 1; // smaller batch size for development private const BATCH_SIZE_PRODUCTION = 5_000; private const BATCH_AGGREGATION_INTERVAL = 60; // in seconds From 6e82bfe8e7d92d2f7c4424cfaf64a6e9c9f855ea Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Wed, 26 Feb 2025 14:00:16 +1300 Subject: [PATCH 16/17] Update date --- app/controllers/api/account.php | 2 +- app/controllers/api/databases.php | 6 +++--- app/controllers/api/messaging.php | 8 ++++---- app/controllers/api/teams.php | 2 +- app/controllers/api/users.php | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 1ba3204134..a634618e6e 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -2717,7 +2717,7 @@ App::get('/v1/account/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index ffe9142251..013e4639cc 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -672,7 +672,7 @@ App::get('/v1/databases/:databaseId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -1068,7 +1068,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -3721,7 +3721,7 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents/:documen // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/messaging.php b/app/controllers/api/messaging.php index 05bb461faf..9393f1fbfe 100644 --- a/app/controllers/api/messaging.php +++ b/app/controllers/api/messaging.php @@ -996,7 +996,7 @@ App::get('/v1/messaging/providers/:providerId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -2226,7 +2226,7 @@ App::get('/v1/messaging/topics/:topicId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -2638,7 +2638,7 @@ App::get('/v1/messaging/subscribers/:subscriberId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); @@ -3405,7 +3405,7 @@ App::get('/v1/messaging/messages/:messageId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index 5fbc1a4e08..b45c9fd3b9 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -1364,7 +1364,7 @@ App::get('/v1/teams/:teamId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); diff --git a/app/controllers/api/users.php b/app/controllers/api/users.php index 0bea1a07f9..4a551b7478 100644 --- a/app/controllers/api/users.php +++ b/app/controllers/api/users.php @@ -864,7 +864,7 @@ App::get('/v1/users/:userId/logs') // Temp fix for logs $queries[] = Query::or([ - Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-25T09:00+00:00'))), + Query::greaterThan('$createdAt', DateTime::format(new \DateTime('2025-02-26T01:30+00:00'))), Query::lessThan('$createdAt', DateTime::format(new \DateTime('2025-02-13T00:00+00:00'))), ]); From 7ea108f015d8b71ed25bb0b48dc3bda99841ec7b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Wed, 26 Feb 2025 08:37:36 +0545 Subject: [PATCH 17/17] Fix: stats resources only queue projects accessed in last 3 hours --- src/Appwrite/Platform/Tasks/StatsResources.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Tasks/StatsResources.php b/src/Appwrite/Platform/Tasks/StatsResources.php index ac3b9ead73..c318f92cf1 100644 --- a/src/Appwrite/Platform/Tasks/StatsResources.php +++ b/src/Appwrite/Platform/Tasks/StatsResources.php @@ -62,7 +62,7 @@ class StatsResources extends Action Authorization::disable(); Authorization::setDefaultStatus(false); - $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours')); + $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('3 hours')); /** * For each project that were accessed in last 24 hours */