mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge branch 'update-sdk-versions' of github.com:appwrite/appwrite into update-sdk-versions
This commit is contained in:
commit
53a86e62d2
2 changed files with 21 additions and 12 deletions
|
|
@ -47,7 +47,8 @@ App::get('/v1/project/usage')
|
||||||
METRIC_USERS,
|
METRIC_USERS,
|
||||||
METRIC_BUCKETS,
|
METRIC_BUCKETS,
|
||||||
METRIC_FILES_STORAGE,
|
METRIC_FILES_STORAGE,
|
||||||
METRIC_DEPLOYMENTS_STORAGE
|
METRIC_DEPLOYMENTS_STORAGE,
|
||||||
|
METRIC_BUILDS_STORAGE
|
||||||
],
|
],
|
||||||
'period' => [
|
'period' => [
|
||||||
METRIC_NETWORK_REQUESTS,
|
METRIC_NETWORK_REQUESTS,
|
||||||
|
|
@ -181,19 +182,27 @@ App::get('/v1/project/usage')
|
||||||
];
|
];
|
||||||
}, $dbForProject->find('buckets'));
|
}, $dbForProject->find('buckets'));
|
||||||
|
|
||||||
$deploymentsStorageBreakdown = array_map(function ($function) use ($dbForProject) {
|
$functionsStorageBreakdown = array_map(function ($function) use ($dbForProject) {
|
||||||
$id = $function->getId();
|
$id = $function->getId();
|
||||||
$name = $function->getAttribute('name');
|
$name = $function->getAttribute('name');
|
||||||
$metric = str_replace(['{resourceType}', '{resourceInternalId}'], ['functions', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE);
|
$deploymentMetric = str_replace(['{resourceType}', '{resourceInternalId}'], ['functions', $function->getInternalId()], METRIC_FUNCTION_ID_DEPLOYMENTS_STORAGE);
|
||||||
$value = $dbForProject->findOne('stats', [
|
$deploymentValue = $dbForProject->findOne('stats', [
|
||||||
Query::equal('metric', [$metric]),
|
Query::equal('metric', [$deploymentMetric]),
|
||||||
Query::equal('period', ['inf'])
|
Query::equal('period', ['inf'])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$buildMetric = str_replace(['{functionInternalId}'], [$function->getInternalId()], METRIC_FUNCTION_ID_BUILDS_STORAGE);
|
||||||
|
$buildValue = $dbForProject->findOne('stats', [
|
||||||
|
Query::equal('metric', [$buildMetric]),
|
||||||
|
Query::equal('period', ['inf'])
|
||||||
|
]);
|
||||||
|
|
||||||
|
$value = ($buildValue['value'] ?? 0) + ($deploymentValue['value'] ?? 0);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'resourceId' => $id,
|
'resourceId' => $id,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'value' => $value['value'] ?? 0,
|
'value' => $value,
|
||||||
];
|
];
|
||||||
}, $dbForProject->find('functions'));
|
}, $dbForProject->find('functions'));
|
||||||
|
|
||||||
|
|
@ -263,14 +272,14 @@ App::get('/v1/project/usage')
|
||||||
'usersTotal' => $total[METRIC_USERS],
|
'usersTotal' => $total[METRIC_USERS],
|
||||||
'bucketsTotal' => $total[METRIC_BUCKETS],
|
'bucketsTotal' => $total[METRIC_BUCKETS],
|
||||||
'filesStorageTotal' => $total[METRIC_FILES_STORAGE],
|
'filesStorageTotal' => $total[METRIC_FILES_STORAGE],
|
||||||
'deploymentsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE],
|
'functionsStorageTotal' => $total[METRIC_DEPLOYMENTS_STORAGE] + $total[METRIC_BUILDS_STORAGE],
|
||||||
'executionsBreakdown' => $executionsBreakdown,
|
'executionsBreakdown' => $executionsBreakdown,
|
||||||
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
|
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
|
||||||
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
|
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
|
||||||
'bucketsBreakdown' => $bucketsBreakdown,
|
'bucketsBreakdown' => $bucketsBreakdown,
|
||||||
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
|
'executionsMbSecondsBreakdown' => $executionsMbSecondsBreakdown,
|
||||||
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
|
'buildsMbSecondsBreakdown' => $buildsMbSecondsBreakdown,
|
||||||
'deploymentsStorageBreakdown' => $deploymentsStorageBreakdown,
|
'functionsStorageBreakdown' => $functionsStorageBreakdown,
|
||||||
]), Response::MODEL_USAGE_PROJECT);
|
]), Response::MODEL_USAGE_PROJECT);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ class UsageProject extends Model
|
||||||
'default' => 0,
|
'default' => 0,
|
||||||
'example' => 0,
|
'example' => 0,
|
||||||
])
|
])
|
||||||
->addRule('deploymentsStorageTotal', [
|
->addRule('functionsStorageTotal', [
|
||||||
'type' => self::TYPE_INTEGER,
|
'type' => self::TYPE_INTEGER,
|
||||||
'description' => 'Total aggregated sum of deployments storage size (in bytes).',
|
'description' => 'Total aggregated sum of functions storage size (in bytes).',
|
||||||
'default' => 0,
|
'default' => 0,
|
||||||
'example' => 0,
|
'example' => 0,
|
||||||
])
|
])
|
||||||
|
|
@ -120,9 +120,9 @@ class UsageProject extends Model
|
||||||
'example' => [],
|
'example' => [],
|
||||||
'array' => true
|
'array' => true
|
||||||
])
|
])
|
||||||
->addRule('deploymentsStorageBreakdown', [
|
->addRule('functionsStorageBreakdown', [
|
||||||
'type' => Response::MODEL_METRIC_BREAKDOWN,
|
'type' => Response::MODEL_METRIC_BREAKDOWN,
|
||||||
'description' => 'Aggregated breakdown in totals of deployments storage size (in bytes).',
|
'description' => 'Aggregated breakdown in totals of functions storage size (in bytes).',
|
||||||
'default' => [],
|
'default' => [],
|
||||||
'example' => [],
|
'example' => [],
|
||||||
'array' => true
|
'array' => true
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue