From aa17eeb6e356c15544296aab6cef84cb3a789c4e Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 28 Dec 2025 14:19:28 +0545 Subject: [PATCH 01/12] Disable filters for platform and project databases - Stat resources - Disable filters for platform and project databases - Stat resources --- src/Appwrite/Platform/Workers/StatsResources.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 1ef348091a..4aeef308ae 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -100,6 +100,9 @@ class StatsResources extends Action return; } + $dbForPlatform->disableFilters(); + $dbForProject->disableFilters(); + try { $region = $project->getAttribute('region'); From b32dd316e12922a4baa543ea2c16a1e404f30a7b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 28 Dec 2025 09:09:11 +0000 Subject: [PATCH 02/12] Fix: use skip filters instead --- .../Platform/Workers/StatsResources.php | 154 +++++++++--------- 1 file changed, 78 insertions(+), 76 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 4aeef308ae..2988092d47 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -77,7 +77,7 @@ class StatsResources extends Action $this->documents = []; $startTime = microtime(true); - $this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project); + $dbForPlatform->skipFilters(fn () => $this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project)); $endTime = microtime(true); $executionTime = $endTime - $startTime; Console::info('Project: ' . $project->getId() . '(' . $project->getSequence() . ') aggregated in ' . $executionTime .' seconds'); @@ -104,7 +104,6 @@ class StatsResources extends Action $dbForProject->disableFilters(); try { - $region = $project->getAttribute('region'); $platforms = $dbForPlatform->count('platforms', [ @@ -123,88 +122,91 @@ class StatsResources extends Action ]); - $databases = $dbForProject->count('databases'); - $buckets = $dbForProject->count('buckets'); - $users = $dbForProject->count('users'); + $dbForProject->skipFilters(function () use ($dbForProject, $dbForLogs, $region, $project, $platforms, $webhooks, $keys, $domains) { + $databases = $dbForProject->count('databases'); + $buckets = $dbForProject->count('buckets'); + $users = $dbForProject->count('users'); - $last30Days = (new \DateTime())->sub(\DateInterval::createFromDateString('30 days'))->format('Y-m-d 00:00:00'); - $usersMAU = $dbForProject->count('users', [ - Query::greaterThanEqual('accessedAt', $last30Days) - ]); - $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours'))->format('Y-m-d h:m:00'); - $usersDAU = $dbForProject->count('users', [ - Query::greaterThanEqual('accessedAt', $last24Hours) - ]); - $last7Days = (new \DateTime())->sub(\DateInterval::createFromDateString('7 days'))->format('Y-m-d 00:00:00'); - $usersWAU = $dbForProject->count('users', [ - Query::greaterThanEqual('accessedAt', $last7Days) - ]); - $teams = $dbForProject->count('teams'); - $functions = $dbForProject->count('functions'); + $last30Days = (new \DateTime())->sub(\DateInterval::createFromDateString('30 days'))->format('Y-m-d 00:00:00'); + $usersMAU = $dbForProject->count('users', [ + Query::greaterThanEqual('accessedAt', $last30Days) + ]); + $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours'))->format('Y-m-d h:m:00'); + $usersDAU = $dbForProject->count('users', [ + Query::greaterThanEqual('accessedAt', $last24Hours) + ]); + $last7Days = (new \DateTime())->sub(\DateInterval::createFromDateString('7 days'))->format('Y-m-d 00:00:00'); + $usersWAU = $dbForProject->count('users', [ + Query::greaterThanEqual('accessedAt', $last7Days) + ]); + $teams = $dbForProject->count('teams'); + $functions = $dbForProject->count('functions'); - $messages = $dbForProject->count('messages'); - $providers = $dbForProject->count('providers'); - $topics = $dbForProject->count('topics'); - $targets = $dbForProject->count('targets'); - $emailTargets = $dbForProject->count('targets', [ - Query::equal('providerType', [MESSAGE_TYPE_EMAIL]) - ]); - $pushTargets = $dbForProject->count('targets', [ - Query::equal('providerType', [MESSAGE_TYPE_PUSH]) - ]); - $smsTargets = $dbForProject->count('targets', [ - Query::equal('providerType', [MESSAGE_TYPE_SMS]) - ]); + $messages = $dbForProject->count('messages'); + $providers = $dbForProject->count('providers'); + $topics = $dbForProject->count('topics'); + $targets = $dbForProject->count('targets'); + $emailTargets = $dbForProject->count('targets', [ + Query::equal('providerType', [MESSAGE_TYPE_EMAIL]) + ]); + $pushTargets = $dbForProject->count('targets', [ + Query::equal('providerType', [MESSAGE_TYPE_PUSH]) + ]); + $smsTargets = $dbForProject->count('targets', [ + Query::equal('providerType', [MESSAGE_TYPE_SMS]) + ]); - $metrics = [ - METRIC_DATABASES => $databases, - METRIC_BUCKETS => $buckets, - METRIC_USERS => $users, - METRIC_FUNCTIONS => $functions, - METRIC_TEAMS => $teams, - METRIC_MESSAGES => $messages, - METRIC_MAU => $usersMAU, - METRIC_DAU => $usersDAU, - METRIC_WAU => $usersWAU, - METRIC_WEBHOOKS => $webhooks, - METRIC_PLATFORMS => $platforms, - METRIC_PROVIDERS => $providers, - METRIC_TOPICS => $topics, - METRIC_KEYS => $keys, - METRIC_DOMAINS => $domains, - METRIC_TARGETS => $targets, - str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets, - str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets, - str_replace('{providerType}', MESSAGE_TYPE_SMS, METRIC_PROVIDER_TYPE_TARGETS) => $smsTargets, - ]; + $metrics = [ + METRIC_DATABASES => $databases, + METRIC_BUCKETS => $buckets, + METRIC_USERS => $users, + METRIC_FUNCTIONS => $functions, + METRIC_TEAMS => $teams, + METRIC_MESSAGES => $messages, + METRIC_MAU => $usersMAU, + METRIC_DAU => $usersDAU, + METRIC_WAU => $usersWAU, + METRIC_WEBHOOKS => $webhooks, + METRIC_PLATFORMS => $platforms, + METRIC_PROVIDERS => $providers, + METRIC_TOPICS => $topics, + METRIC_KEYS => $keys, + METRIC_DOMAINS => $domains, + METRIC_TARGETS => $targets, + str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets, + str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets, + str_replace('{providerType}', MESSAGE_TYPE_SMS, METRIC_PROVIDER_TYPE_TARGETS) => $smsTargets, + ]; - foreach ($metrics as $metric => $value) { - $this->createStatsDocuments($region, $metric, $value); - } + foreach ($metrics as $metric => $value) { + $this->createStatsDocuments($region, $metric, $value); + } - try { - $this->countForBuckets($dbForProject, $dbForLogs, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); - } + try { + $this->countForBuckets($dbForProject, $dbForLogs, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); + } - try { - $this->countImageTransformations($dbForProject, $dbForLogs, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); - } + try { + $this->countImageTransformations($dbForProject, $dbForLogs, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); + } - try { - $this->countForDatabase($dbForProject, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); - } + try { + $this->countForDatabase($dbForProject, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); + } + + try { + $this->countForSitesAndFunctions($dbForProject, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); + } + }); - try { - $this->countForSitesAndFunctions($dbForProject, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); - } $this->writeDocuments($dbForLogs, $project); } catch (Throwable $th) { From 61c619f3734180118ca467359f03e26fb8eeec79 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 28 Dec 2025 09:27:21 +0000 Subject: [PATCH 03/12] remove disables --- src/Appwrite/Platform/Workers/StatsResources.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 2988092d47..3e2fa046b4 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -100,8 +100,6 @@ class StatsResources extends Action return; } - $dbForPlatform->disableFilters(); - $dbForProject->disableFilters(); try { $region = $project->getAttribute('region'); From 08f30224b6a045f96d4ee69c5114722a34793bd3 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 28 Dec 2025 10:26:21 +0000 Subject: [PATCH 04/12] Use disable instead of skip agin --- .../Platform/Workers/StatsResources.php | 157 +++++++++--------- 1 file changed, 78 insertions(+), 79 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 3e2fa046b4..b48b008ce2 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -77,7 +77,7 @@ class StatsResources extends Action $this->documents = []; $startTime = microtime(true); - $dbForPlatform->skipFilters(fn () => $this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project)); + $this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project); $endTime = microtime(true); $executionTime = $endTime - $startTime; Console::info('Project: ' . $project->getId() . '(' . $project->getSequence() . ') aggregated in ' . $executionTime .' seconds'); @@ -99,7 +99,9 @@ class StatsResources extends Action Console::error($th->getMessage()); return; } - + + $dbForPlatform->disableFilters(); + $dbForProject->disableFilters(); try { $region = $project->getAttribute('region'); @@ -120,91 +122,88 @@ class StatsResources extends Action ]); - $dbForProject->skipFilters(function () use ($dbForProject, $dbForLogs, $region, $project, $platforms, $webhooks, $keys, $domains) { - $databases = $dbForProject->count('databases'); - $buckets = $dbForProject->count('buckets'); - $users = $dbForProject->count('users'); + $databases = $dbForProject->count('databases'); + $buckets = $dbForProject->count('buckets'); + $users = $dbForProject->count('users'); - $last30Days = (new \DateTime())->sub(\DateInterval::createFromDateString('30 days'))->format('Y-m-d 00:00:00'); - $usersMAU = $dbForProject->count('users', [ - Query::greaterThanEqual('accessedAt', $last30Days) - ]); - $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours'))->format('Y-m-d h:m:00'); - $usersDAU = $dbForProject->count('users', [ - Query::greaterThanEqual('accessedAt', $last24Hours) - ]); - $last7Days = (new \DateTime())->sub(\DateInterval::createFromDateString('7 days'))->format('Y-m-d 00:00:00'); - $usersWAU = $dbForProject->count('users', [ - Query::greaterThanEqual('accessedAt', $last7Days) - ]); - $teams = $dbForProject->count('teams'); - $functions = $dbForProject->count('functions'); + $last30Days = (new \DateTime())->sub(\DateInterval::createFromDateString('30 days'))->format('Y-m-d 00:00:00'); + $usersMAU = $dbForProject->count('users', [ + Query::greaterThanEqual('accessedAt', $last30Days) + ]); + $last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours'))->format('Y-m-d h:m:00'); + $usersDAU = $dbForProject->count('users', [ + Query::greaterThanEqual('accessedAt', $last24Hours) + ]); + $last7Days = (new \DateTime())->sub(\DateInterval::createFromDateString('7 days'))->format('Y-m-d 00:00:00'); + $usersWAU = $dbForProject->count('users', [ + Query::greaterThanEqual('accessedAt', $last7Days) + ]); + $teams = $dbForProject->count('teams'); + $functions = $dbForProject->count('functions'); - $messages = $dbForProject->count('messages'); - $providers = $dbForProject->count('providers'); - $topics = $dbForProject->count('topics'); - $targets = $dbForProject->count('targets'); - $emailTargets = $dbForProject->count('targets', [ - Query::equal('providerType', [MESSAGE_TYPE_EMAIL]) - ]); - $pushTargets = $dbForProject->count('targets', [ - Query::equal('providerType', [MESSAGE_TYPE_PUSH]) - ]); - $smsTargets = $dbForProject->count('targets', [ - Query::equal('providerType', [MESSAGE_TYPE_SMS]) - ]); + $messages = $dbForProject->count('messages'); + $providers = $dbForProject->count('providers'); + $topics = $dbForProject->count('topics'); + $targets = $dbForProject->count('targets'); + $emailTargets = $dbForProject->count('targets', [ + Query::equal('providerType', [MESSAGE_TYPE_EMAIL]) + ]); + $pushTargets = $dbForProject->count('targets', [ + Query::equal('providerType', [MESSAGE_TYPE_PUSH]) + ]); + $smsTargets = $dbForProject->count('targets', [ + Query::equal('providerType', [MESSAGE_TYPE_SMS]) + ]); - $metrics = [ - METRIC_DATABASES => $databases, - METRIC_BUCKETS => $buckets, - METRIC_USERS => $users, - METRIC_FUNCTIONS => $functions, - METRIC_TEAMS => $teams, - METRIC_MESSAGES => $messages, - METRIC_MAU => $usersMAU, - METRIC_DAU => $usersDAU, - METRIC_WAU => $usersWAU, - METRIC_WEBHOOKS => $webhooks, - METRIC_PLATFORMS => $platforms, - METRIC_PROVIDERS => $providers, - METRIC_TOPICS => $topics, - METRIC_KEYS => $keys, - METRIC_DOMAINS => $domains, - METRIC_TARGETS => $targets, - str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets, - str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets, - str_replace('{providerType}', MESSAGE_TYPE_SMS, METRIC_PROVIDER_TYPE_TARGETS) => $smsTargets, - ]; + $metrics = [ + METRIC_DATABASES => $databases, + METRIC_BUCKETS => $buckets, + METRIC_USERS => $users, + METRIC_FUNCTIONS => $functions, + METRIC_TEAMS => $teams, + METRIC_MESSAGES => $messages, + METRIC_MAU => $usersMAU, + METRIC_DAU => $usersDAU, + METRIC_WAU => $usersWAU, + METRIC_WEBHOOKS => $webhooks, + METRIC_PLATFORMS => $platforms, + METRIC_PROVIDERS => $providers, + METRIC_TOPICS => $topics, + METRIC_KEYS => $keys, + METRIC_DOMAINS => $domains, + METRIC_TARGETS => $targets, + str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets, + str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets, + str_replace('{providerType}', MESSAGE_TYPE_SMS, METRIC_PROVIDER_TYPE_TARGETS) => $smsTargets, + ]; - foreach ($metrics as $metric => $value) { - $this->createStatsDocuments($region, $metric, $value); - } + foreach ($metrics as $metric => $value) { + $this->createStatsDocuments($region, $metric, $value); + } - try { - $this->countForBuckets($dbForProject, $dbForLogs, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); - } + try { + $this->countForBuckets($dbForProject, $dbForLogs, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); + } - try { - $this->countImageTransformations($dbForProject, $dbForLogs, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); - } + try { + $this->countImageTransformations($dbForProject, $dbForLogs, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); + } - try { - $this->countForDatabase($dbForProject, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); - } - - try { - $this->countForSitesAndFunctions($dbForProject, $region); - } catch (Throwable $th) { - call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); - } - }); + try { + $this->countForDatabase($dbForProject, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); + } + try { + $this->countForSitesAndFunctions($dbForProject, $region); + } catch (Throwable $th) { + call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); + } $this->writeDocuments($dbForLogs, $project); } catch (Throwable $th) { From 9c8f565211c16a877010c944efb88d9c0677c093 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 28 Dec 2025 10:33:12 +0000 Subject: [PATCH 05/12] use the helper method instead --- src/Appwrite/Platform/Workers/StatsResources.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index b48b008ce2..f6578100f0 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -100,8 +100,7 @@ class StatsResources extends Action return; } - $dbForPlatform->disableFilters(); - $dbForProject->disableFilters(); + $this->disableSubqueries(); try { $region = $project->getAttribute('region'); From 126de78ce2dfa6864a2cc11e5e334f47fa9ecca2 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 14:13:56 +0200 Subject: [PATCH 06/12] skip functions --- src/Appwrite/Platform/Action.php | 2 +- src/Appwrite/Platform/Workers/StatsResources.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/Platform/Action.php b/src/Appwrite/Platform/Action.php index 3db0c74d45..e2df7652b7 100644 --- a/src/Appwrite/Platform/Action.php +++ b/src/Appwrite/Platform/Action.php @@ -46,7 +46,7 @@ class Action extends UtopiaAction * * @return void */ - protected function foreachDocument(Database $database, string $collection, array $queries = [], callable $callback = null, int $limit = 1000, bool $concurrent = false): void + protected function foreachDocument(Database $database, string $collection, array $queries = [], callable $callback = null, int $limit = 1000, bool $concurrent = false, bool $filters = true): void { $results = []; $sum = $limit; diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index f6578100f0..8fd74a6b89 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -199,7 +199,7 @@ class StatsResources extends Action } try { - $this->countForSitesAndFunctions($dbForProject, $region); + $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region)); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); } From 7a89779827731c4036c7b852253002ca17fc3307 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 14:17:48 +0200 Subject: [PATCH 07/12] revert --- src/Appwrite/Platform/Action.php | 2 +- src/Appwrite/Platform/Workers/StatsResources.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/Platform/Action.php b/src/Appwrite/Platform/Action.php index e2df7652b7..3db0c74d45 100644 --- a/src/Appwrite/Platform/Action.php +++ b/src/Appwrite/Platform/Action.php @@ -46,7 +46,7 @@ class Action extends UtopiaAction * * @return void */ - protected function foreachDocument(Database $database, string $collection, array $queries = [], callable $callback = null, int $limit = 1000, bool $concurrent = false, bool $filters = true): void + protected function foreachDocument(Database $database, string $collection, array $queries = [], callable $callback = null, int $limit = 1000, bool $concurrent = false): void { $results = []; $sum = $limit; diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 8fd74a6b89..407cbfca8a 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -99,10 +99,9 @@ class StatsResources extends Action Console::error($th->getMessage()); return; } - - $this->disableSubqueries(); try { + $region = $project->getAttribute('region'); $platforms = $dbForPlatform->count('platforms', [ From 472e2c282df930fa708c9050eff4d61be6f8ab39 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 14:31:46 +0200 Subject: [PATCH 08/12] skip specific filters --- src/Appwrite/Platform/Workers/StatsResources.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 407cbfca8a..f23fe09430 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -180,25 +180,25 @@ class StatsResources extends Action } try { - $this->countForBuckets($dbForProject, $dbForLogs, $region); + $dbForProject->skipFilters(fn () => $this->countForBuckets($dbForProject, $dbForLogs, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $this->countImageTransformations($dbForProject, $dbForLogs, $region); + $dbForProject->skipFilters(fn () => $this->countImageTransformations($dbForProject, $dbForLogs, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $this->countForDatabase($dbForProject, $region); + $dbForProject->skipFilters(fn () => $this->countForDatabase($dbForProject, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region)); + $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); } From bd9f02b689c74a1c2d986ebc054c531524c2233e Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 15:01:29 +0200 Subject: [PATCH 09/12] Only functions --- src/Appwrite/Platform/Action.php | 4 ++-- src/Appwrite/Platform/Workers/StatsResources.php | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Action.php b/src/Appwrite/Platform/Action.php index 3db0c74d45..356209ef6f 100644 --- a/src/Appwrite/Platform/Action.php +++ b/src/Appwrite/Platform/Action.php @@ -22,9 +22,9 @@ class Action extends UtopiaAction protected mixed $logError; protected array $filters = [ - 'subQueryKeys', 'subQueryWebhooks', 'subQueryPlatforms', 'subQueryProjectVariables', 'subQueryBlocks', 'subQueryDevKeys', // Project + 'subQueryKeys', 'subQueryWebhooks', 'subQueryPlatforms', 'subQueryBlocks', 'subQueryDevKeys', // Project 'subQueryAuthenticators', 'subQuerySessions', 'subQueryTokens', 'subQueryChallenges', 'subQueryMemberships', 'subQueryTargets', 'subQueryTopicTargets',// Users - 'subQueryVariables', // Sites + 'subQueryVariables', 'subQueryProjectVariables' // Sites / Functions ]; /** diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index f23fe09430..8442f89d21 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -180,19 +180,19 @@ class StatsResources extends Action } try { - $dbForProject->skipFilters(fn () => $this->countForBuckets($dbForProject, $dbForLogs, $region), $this->filters); + $this->countForBuckets($dbForProject, $dbForLogs, $region); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countImageTransformations($dbForProject, $dbForLogs, $region), $this->filters); + $this->countImageTransformations($dbForProject, $dbForLogs, $region); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countForDatabase($dbForProject, $region), $this->filters); + $this->countForDatabase($dbForProject, $region); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); } From c463a9a6621007c4a01e802edf9ccdd3dfa96e8c Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 15:14:56 +0200 Subject: [PATCH 10/12] Only functions --- src/Appwrite/Platform/Workers/StatsResources.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index 8442f89d21..f8a14d03a5 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -198,7 +198,8 @@ class StatsResources extends Action } try { - $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), $this->filters); + $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), ['subQueryVariables', 'subQueryProjectVariables']); + } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); } From d583b5e2280842afee72cc23f729157c69b6202f Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 15:33:00 +0200 Subject: [PATCH 11/12] All again --- src/Appwrite/Platform/Workers/StatsResources.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index f8a14d03a5..f23fe09430 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -180,26 +180,25 @@ class StatsResources extends Action } try { - $this->countForBuckets($dbForProject, $dbForLogs, $region); + $dbForProject->skipFilters(fn () => $this->countForBuckets($dbForProject, $dbForLogs, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $this->countImageTransformations($dbForProject, $dbForLogs, $region); + $dbForProject->skipFilters(fn () => $this->countImageTransformations($dbForProject, $dbForLogs, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $this->countForDatabase($dbForProject, $region); + $dbForProject->skipFilters(fn () => $this->countForDatabase($dbForProject, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), ['subQueryVariables', 'subQueryProjectVariables']); - + $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), $this->filters); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); } From 5d9201466b19051852f1a78826680ca9d5674198 Mon Sep 17 00:00:00 2001 From: fogelito Date: Sun, 28 Dec 2025 16:54:38 +0200 Subject: [PATCH 12/12] functions + databases --- src/Appwrite/Platform/Workers/StatsResources.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Appwrite/Platform/Workers/StatsResources.php b/src/Appwrite/Platform/Workers/StatsResources.php index f23fe09430..e465f9cca2 100644 --- a/src/Appwrite/Platform/Workers/StatsResources.php +++ b/src/Appwrite/Platform/Workers/StatsResources.php @@ -180,25 +180,25 @@ class StatsResources extends Action } try { - $dbForProject->skipFilters(fn () => $this->countForBuckets($dbForProject, $dbForLogs, $region), $this->filters); + $this->countForBuckets($dbForProject, $dbForLogs, $region); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countImageTransformations($dbForProject, $dbForLogs, $region), $this->filters); + $this->countImageTransformations($dbForProject, $dbForLogs, $region); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countForDatabase($dbForProject, $region), $this->filters); + $dbForProject->skipFilters(fn () => $this->countForDatabase($dbForProject, $region), ['subQueryAttributes', 'subQueryIndexes']); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]); } try { - $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), $this->filters); + $dbForProject->skipFilters(fn () => $this->countForSitesAndFunctions($dbForProject, $region), ['subQueryVariables', 'subQueryProjectVariables']); } catch (Throwable $th) { call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]); }