feat: add databases and buckets to projects usage

This commit is contained in:
Torsten Dittmann
2022-11-08 13:09:18 +01:00
parent be642762b3
commit 4befb19c35
3 changed files with 15 additions and 5 deletions
+4 -2
View File
@@ -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]] ?? [],
]);
}
@@ -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
])
;
}
@@ -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']);