From 3cd31e2c069a52a9a3f64021efdb209c85f03b6a Mon Sep 17 00:00:00 2001 From: Christy Jacob Date: Wed, 25 Jun 2025 21:46:15 +0400 Subject: [PATCH] Add disableSubqueries method to Action class and integrate it into StatsResources initialization --- src/Appwrite/Platform/Action.php | 21 +++++++++++++++++++ .../Platform/Tasks/StatsResources.php | 8 ++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Action.php b/src/Appwrite/Platform/Action.php index 72c41582ea..cd06df74fe 100644 --- a/src/Appwrite/Platform/Action.php +++ b/src/Appwrite/Platform/Action.php @@ -87,4 +87,25 @@ class Action extends UtopiaAction $latestDocument = $results[array_key_last($results)]; } } + + public function disableSubqueries() + { + $filters = [ + 'subQueryKeys', 'subQueryWebhooks', 'subQueryPlatforms', 'subQueryProjectVariables', 'subQueryBlocks', 'subQueryDevKeys', // Project + 'subQueryAuthenticators', 'subQuerySessions', 'subQueryTokens', 'subQueryChallenges', 'subQueryMemberships', 'subQueryTargets', 'subQueryTopicTargets',// Users + 'subQueryVariables', // Sites + ]; + + foreach ($filters as $filter) { + Database::addFilter( + $filter, + function (mixed $value) { + return; + }, + function (mixed $value, Document $document, Database $database) { + return []; + } + ); + } + } } diff --git a/src/Appwrite/Platform/Tasks/StatsResources.php b/src/Appwrite/Platform/Tasks/StatsResources.php index 0610dd0df6..b64dd61f86 100644 --- a/src/Appwrite/Platform/Tasks/StatsResources.php +++ b/src/Appwrite/Platform/Tasks/StatsResources.php @@ -4,7 +4,6 @@ namespace Appwrite\Platform\Tasks; use Appwrite\Event\StatsResources as EventStatsResources; use Appwrite\Platform\Action; -use Swoole\Timer; use Utopia\CLI\Console; use Utopia\Database\Database; use Utopia\Database\DateTime; @@ -54,12 +53,15 @@ class StatsResources extends Action $this->logError = $logError; $this->dbForPlatform = $dbForPlatform; + $this->disableSubqueries(); + Console::title("Stats resources V1"); Console::success('Stats resources: started'); $interval = (int) System::getEnv('_APP_STATS_RESOURCES_INTERVAL', '3600'); - Timer::tick($interval * 1000, function () use ($queue) { + + Console::loop(function () use ($queue) { Authorization::disable(); Authorization::setDefaultStatus(false); @@ -76,7 +78,7 @@ class StatsResources extends Action ->trigger(); Console::success('project: ' . $project->getId() . '(' . $project->getSequence() . ')' . ' queued'); }); - }); + }, $interval); Console::log("Stats resources: exited"); }