From 0fd7db3c36fb0ac6521759d0bdf11c8f4acbd6a3 Mon Sep 17 00:00:00 2001 From: shimon Date: Tue, 30 May 2023 20:11:25 +0300 Subject: [PATCH] addressing comments --- app/console | 2 +- composer.lock | 2 +- src/Appwrite/Platform/Services/Tasks.php | 2 +- src/Appwrite/Platform/Tasks/CalcTierStats.php | 25 +++++++++++++------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/app/console b/app/console index 3a0c8f0334..9174d8f8cb 160000 --- a/app/console +++ b/app/console @@ -1 +1 @@ -Subproject commit 3a0c8f0334d402a6e27c8b5c0512f3d60080ddbd +Subproject commit 9174d8f8cb584744dd7a53f69d324f490ee82ee3 diff --git a/composer.lock b/composer.lock index 3d9a6c8bda..4057dc70b2 100644 --- a/composer.lock +++ b/composer.lock @@ -5542,5 +5542,5 @@ "platform-overrides": { "php": "8.0" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/src/Appwrite/Platform/Services/Tasks.php b/src/Appwrite/Platform/Services/Tasks.php index e05baee68a..7e8d9a1333 100644 --- a/src/Appwrite/Platform/Services/Tasks.php +++ b/src/Appwrite/Platform/Services/Tasks.php @@ -45,7 +45,7 @@ class Tasks extends Service ->addAction(VolumeSync::getName(), new VolumeSync()) ->addAction(Specs::getName(), new Specs()) ->addAction(CalcUsersStats::getName(), new CalcUsersStats()) - ->addAction(CalctierStats::getName(), new CalcTierStats()) + ->addAction(CalcTierStats::getName(), new CalcTierStats()) ; } } diff --git a/src/Appwrite/Platform/Tasks/CalcTierStats.php b/src/Appwrite/Platform/Tasks/CalcTierStats.php index 28688b8157..bdc46e9780 100644 --- a/src/Appwrite/Platform/Tasks/CalcTierStats.php +++ b/src/Appwrite/Platform/Tasks/CalcTierStats.php @@ -3,6 +3,7 @@ namespace Appwrite\Platform\Tasks; use Exception; +use League\Csv\CannotInsertRecord; use Utopia\App; use Utopia\Database\Validator\Authorization; use Utopia\Platform\Action; @@ -20,17 +21,18 @@ class CalcTierStats extends Action private array $columns = [ 'Project ID', 'Organization ID', - 'Users', + 'Organization Members', 'Teams', 'Requests', 'Bandwidth', 'Domains', + 'Api keys', 'Webhooks', 'Platforms', 'Buckets', 'Files', - 'Storage', - 'Max file size', + 'Storage (bytes)', + 'Max File Size (bytes)', 'Databases', 'Functions', 'Deployments', @@ -66,6 +68,10 @@ class CalcTierStats extends Action }); } + /** + * @throws \Utopia\Exception + * @throws CannotInsertRecord + */ public function action(Group $pools, Cache $cache, Database $dbForConsole, Registry $register): void { //docker compose exec -t appwrite calc-tier-stats @@ -129,12 +135,12 @@ class CalcTierStats extends Action //$teamName = $team->getAttribute('name'); // } - $stats['Organization ID'] = $project->getAttribute('teamInternalId', null); + $stats['Organization ID'] = $project->getAttribute('teamId', null); /** Get Total Members */ $teamInternalId = $project->getAttribute('teamInternalId', null); if ($teamInternalId) { - $stats['Users'] = $dbForConsole->count('memberships', [ + $stats['Organization Members'] = $dbForConsole->count('memberships', [ Query::equal('teamInternalId', [$teamInternalId]) ]); } else { @@ -190,6 +196,11 @@ class CalcTierStats extends Action ]); + /** Get Api keys */ + $stats['Api keys'] = $dbForConsole->count('keys', [ + Query::equal('projectInternalId', [$project->getInternalId()]), + ]); + /** Get Webhooks */ $stats['Webhooks'] = $dbForConsole->count('webhooks', [ Query::equal('projectInternalId', [$project->getInternalId()]), @@ -217,8 +228,8 @@ class CalcTierStats extends Action } $stats['Buckets'] = $counter; $stats['Files'] = $filesCount; - $stats['Storage'] = $filesSum; - $stats['Max file size'] = $maxFileSize; + $stats['Storage (bytes)'] = $filesSum; + $stats['Max File Size (bytes)'] = $maxFileSize; /** Get Total Functions */ $stats['Databases'] = $dbForProject->count('databases', []);