From 4befb19c3526e63d844e6360baccbc65716828d6 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Tue, 8 Nov 2022 13:09:18 +0100 Subject: [PATCH] feat: add databases and buckets to projects usage --- app/controllers/api/projects.php | 6 ++++-- src/Appwrite/Utopia/Response/Model/UsageProject.php | 11 +++++++++-- .../Services/Projects/ProjectsConsoleClientTest.php | 3 ++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 9a5f3f001b..a5c9177f82 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -295,9 +295,10 @@ App::get('/v1/projects/:projectId/usage') 'project.$all.network.bandwidth', 'project.$all.storage.size', 'users.$all.count.total', - 'collections.$all.count.total', + 'databases.$all.count.total', 'documents.$all.count.total', 'executions.$all.compute.total', + 'buckets.$all.count.total' ]; $stats = []; @@ -346,9 +347,10 @@ App::get('/v1/projects/:projectId/usage') 'network' => $stats[$metrics[1]] ?? [], 'storage' => $stats[$metrics[2]] ?? [], 'users' => $stats[$metrics[3]] ?? [], - 'collections' => $stats[$metrics[4]] ?? [], + 'databases' => $stats[$metrics[4]] ?? [], 'documents' => $stats[$metrics[5]] ?? [], 'executions' => $stats[$metrics[6]] ?? [], + 'buckets' => $stats[$metrics[7]] ?? [], ]); } diff --git a/src/Appwrite/Utopia/Response/Model/UsageProject.php b/src/Appwrite/Utopia/Response/Model/UsageProject.php index 01603fce8a..e37bc5928d 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageProject.php +++ b/src/Appwrite/Utopia/Response/Model/UsageProject.php @@ -44,9 +44,9 @@ class UsageProject extends Model 'example' => [], 'array' => true ]) - ->addRule('collections', [ + ->addRule('databases', [ 'type' => Response::MODEL_METRIC, - 'description' => 'Aggregated stats for number of collections.', + 'description' => 'Aggregated stats for number of databases.', 'default' => [], 'example' => [], 'array' => true @@ -65,6 +65,13 @@ class UsageProject extends Model 'example' => [], 'array' => true ]) + ->addRule('buckets', [ + 'type' => Response::MODEL_METRIC, + 'description' => 'Aggregated stats for number of buckets.', + 'default' => [], + 'example' => [], + 'array' => true + ]) ; } diff --git a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php index 29789a322e..6b1d9ccea8 100644 --- a/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php +++ b/tests/e2e/Services/Projects/ProjectsConsoleClientTest.php @@ -342,7 +342,8 @@ class ProjectsConsoleClientTest extends Scope $this->assertIsArray($response['body']['network']); $this->assertIsArray($response['body']['executions']); $this->assertIsArray($response['body']['documents']); - $this->assertIsArray($response['body']['collections']); + $this->assertIsArray($response['body']['databases']); + $this->assertIsArray($response['body']['buckets']); $this->assertIsArray($response['body']['users']); $this->assertIsArray($response['body']['storage']);