From c5dae9f0183bfcf0ac702909a3ac9990fb4d4796 Mon Sep 17 00:00:00 2001 From: Torsten Dittmann Date: Mon, 16 Sep 2024 13:49:13 +0200 Subject: [PATCH] fix: backwards compatibility --- app/config/specs/open-api3-1.6.x-console.json | 7 +++++++ app/config/specs/open-api3-latest-console.json | 7 +++++++ app/config/specs/swagger2-1.6.x-console.json | 7 +++++++ app/config/specs/swagger2-latest-console.json | 7 +++++++ app/controllers/api/project.php | 1 + src/Appwrite/Utopia/Response/Model/UsageProject.php | 6 ++++++ tests/e2e/General/UsageTest.php | 6 +++--- 7 files changed, 38 insertions(+), 3 deletions(-) diff --git a/app/config/specs/open-api3-1.6.x-console.json b/app/config/specs/open-api3-1.6.x-console.json index 99fd60228a..07749889d8 100644 --- a/app/config/specs/open-api3-1.6.x-console.json +++ b/app/config/specs/open-api3-1.6.x-console.json @@ -37378,6 +37378,12 @@ "x-example": 0, "format": "int32" }, + "functionsStorageTotal": { + "type": "integer", + "description": "Total aggregated sum of functions storage size (in bytes).", + "x-example": 0, + "format": "int32" + }, "buildsStorageTotal": { "type": "integer", "description": "Total aggregated sum of builds storage size (in bytes).", @@ -37487,6 +37493,7 @@ "databasesTotal", "usersTotal", "filesStorageTotal", + "functionsStorageTotal", "buildsStorageTotal", "deploymentsStorageTotal", "bucketsTotal", diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 99fd60228a..07749889d8 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -37378,6 +37378,12 @@ "x-example": 0, "format": "int32" }, + "functionsStorageTotal": { + "type": "integer", + "description": "Total aggregated sum of functions storage size (in bytes).", + "x-example": 0, + "format": "int32" + }, "buildsStorageTotal": { "type": "integer", "description": "Total aggregated sum of builds storage size (in bytes).", @@ -37487,6 +37493,7 @@ "databasesTotal", "usersTotal", "filesStorageTotal", + "functionsStorageTotal", "buildsStorageTotal", "deploymentsStorageTotal", "bucketsTotal", diff --git a/app/config/specs/swagger2-1.6.x-console.json b/app/config/specs/swagger2-1.6.x-console.json index b1a45d3288..51935a5e01 100644 --- a/app/config/specs/swagger2-1.6.x-console.json +++ b/app/config/specs/swagger2-1.6.x-console.json @@ -37933,6 +37933,12 @@ "x-example": 0, "format": "int32" }, + "functionsStorageTotal": { + "type": "integer", + "description": "Total aggregated sum of functions storage size (in bytes).", + "x-example": 0, + "format": "int32" + }, "buildsStorageTotal": { "type": "integer", "description": "Total aggregated sum of builds storage size (in bytes).", @@ -38051,6 +38057,7 @@ "databasesTotal", "usersTotal", "filesStorageTotal", + "functionsStorageTotal", "buildsStorageTotal", "deploymentsStorageTotal", "bucketsTotal", diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index b1a45d3288..51935a5e01 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -37933,6 +37933,12 @@ "x-example": 0, "format": "int32" }, + "functionsStorageTotal": { + "type": "integer", + "description": "Total aggregated sum of functions storage size (in bytes).", + "x-example": 0, + "format": "int32" + }, "buildsStorageTotal": { "type": "integer", "description": "Total aggregated sum of builds storage size (in bytes).", @@ -38051,6 +38057,7 @@ "databasesTotal", "usersTotal", "filesStorageTotal", + "functionsStorageTotal", "buildsStorageTotal", "deploymentsStorageTotal", "bucketsTotal", diff --git a/app/controllers/api/project.php b/app/controllers/api/project.php index 49c902d65b..d885e980df 100644 --- a/app/controllers/api/project.php +++ b/app/controllers/api/project.php @@ -272,6 +272,7 @@ App::get('/v1/project/usage') 'usersTotal' => $total[METRIC_USERS], 'bucketsTotal' => $total[METRIC_BUCKETS], 'filesStorageTotal' => $total[METRIC_FILES_STORAGE], + 'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE], 'buildsStorageTotal' => $total[METRIC_BUILDS_STORAGE], 'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE], 'executionsBreakdown' => $executionsBreakdown, diff --git a/src/Appwrite/Utopia/Response/Model/UsageProject.php b/src/Appwrite/Utopia/Response/Model/UsageProject.php index 1128c0d578..2703691238 100644 --- a/src/Appwrite/Utopia/Response/Model/UsageProject.php +++ b/src/Appwrite/Utopia/Response/Model/UsageProject.php @@ -40,6 +40,12 @@ class UsageProject extends Model 'default' => 0, 'example' => 0, ]) + ->addRule('functionsStorageTotal', [ + 'type' => self::TYPE_INTEGER, + 'description' => 'Total aggregated sum of functions storage size (in bytes).', + 'default' => 0, + 'example' => 0, + ]) ->addRule('buildsStorageTotal', [ 'type' => self::TYPE_INTEGER, 'description' => 'Total aggregated sum of builds storage size (in bytes).', diff --git a/tests/e2e/General/UsageTest.php b/tests/e2e/General/UsageTest.php index 910c0e3824..d3623acffc 100644 --- a/tests/e2e/General/UsageTest.php +++ b/tests/e2e/General/UsageTest.php @@ -143,7 +143,7 @@ class UsageTest extends Scope ); $this->assertEquals(200, $response['headers']['status-code']); - $this->assertEquals(19, count($response['body'])); + $this->assertEquals(20, count($response['body'])); $this->validateDates($response['body']['network']); $this->validateDates($response['body']['requests']); $this->validateDates($response['body']['users']); @@ -324,7 +324,7 @@ class UsageTest extends Scope ] ); - $this->assertEquals(19, count($response['body'])); + $this->assertEquals(20, count($response['body'])); $this->assertEquals(1, count($response['body']['requests'])); $this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']); $this->validateDates($response['body']['requests']); @@ -545,7 +545,7 @@ class UsageTest extends Scope ] ); - $this->assertEquals(19, count($response['body'])); + $this->assertEquals(20, count($response['body'])); $this->assertEquals(1, count($response['body']['requests'])); $this->assertEquals(1, count($response['body']['network'])); $this->assertEquals($requestsTotal, $response['body']['requests'][array_key_last($response['body']['requests'])]['value']);