added bucketInternalId to file
This commit is contained in:
parent
9bbab6afeb
commit
1e29ec8d59
4 changed files with 17 additions and 6 deletions
|
@ -3410,6 +3410,17 @@ $collections = [
|
||||||
'default' => null,
|
'default' => null,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'array' => false,
|
||||||
|
'$id' => ID::custom('bucketInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => true,
|
||||||
|
'default' => null,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('name'),
|
'$id' => ID::custom('name'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
|
|
@ -561,6 +561,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
|
||||||
'$id' => $fileId,
|
'$id' => $fileId,
|
||||||
'$permissions' => $permissions,
|
'$permissions' => $permissions,
|
||||||
'bucketId' => $bucket->getId(),
|
'bucketId' => $bucket->getId(),
|
||||||
|
'bucketInternalId' => $bucket->getInternalId(),
|
||||||
'name' => $fileName,
|
'name' => $fileName,
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
'signature' => $fileHash,
|
'signature' => $fileHash,
|
||||||
|
@ -610,6 +611,7 @@ App::post('/v1/storage/buckets/:bucketId/files')
|
||||||
'$id' => ID::custom($fileId),
|
'$id' => ID::custom($fileId),
|
||||||
'$permissions' => $permissions,
|
'$permissions' => $permissions,
|
||||||
'bucketId' => $bucket->getId(),
|
'bucketId' => $bucket->getId(),
|
||||||
|
'bucketInternalId' => $bucket->getInternalId(),
|
||||||
'name' => $fileName,
|
'name' => $fileName,
|
||||||
'path' => $path,
|
'path' => $path,
|
||||||
'signature' => '',
|
'signature' => '',
|
||||||
|
|
|
@ -112,13 +112,11 @@ $databaseListener = function (string $event, Document $document, Document $proje
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case str_starts_with($document->getCollection(), 'bucket_'): // files
|
case str_starts_with($document->getCollection(), 'bucket_'): // files
|
||||||
$parts = explode('_', $document->getCollection());
|
|
||||||
$bucketInternalId = $parts[1];
|
|
||||||
$queueForUsage
|
$queueForUsage
|
||||||
->addMetric(METRIC_FILES, $value) // per project
|
->addMetric(METRIC_FILES, $value) // per project
|
||||||
->addMetric(METRIC_FILES_STORAGE, $document->getAttribute('sizeOriginal') * $value) // per project
|
->addMetric(METRIC_FILES_STORAGE, $document->getAttribute('sizeOriginal') * $value) // per project
|
||||||
->addMetric(str_replace('{bucketInternalId}', $bucketInternalId, METRIC_BUCKET_ID_FILES), $value) // per bucket
|
->addMetric(str_replace('{bucketInternalId}', $document->getAttribute('bucketInternalId'), METRIC_BUCKET_ID_FILES), $value) // per bucket
|
||||||
->addMetric(str_replace('{bucketInternalId}', $bucketInternalId, METRIC_BUCKET_ID_FILES_STORAGE), $document->getAttribute('sizeOriginal') * $value); // per bucket
|
->addMetric(str_replace('{bucketInternalId}', $document->getAttribute('bucketInternalId'), METRIC_BUCKET_ID_FILES_STORAGE), $document->getAttribute('sizeOriginal') * $value); // per bucket
|
||||||
break;
|
break;
|
||||||
case $document->getCollection() === 'functions':
|
case $document->getCollection() === 'functions':
|
||||||
$queueForUsage
|
$queueForUsage
|
||||||
|
|
|
@ -28,8 +28,8 @@ $periods['inf'] = '0000-00-00 00:00';
|
||||||
const INFINITI_PERIOD = '_inf_';
|
const INFINITI_PERIOD = '_inf_';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On Documents that tied by relations like functions>deployments>build || documents>collection>database || buckets>files
|
* On Documents that tied by relations like functions>deployments>build || documents>collection>database || buckets>files.
|
||||||
* When we remove a parent document we need to deduct his children aggregation from the project scope
|
* When we remove a parent document we need to deduct his children aggregation from the project scope.
|
||||||
*/
|
*/
|
||||||
Server::setResource('reduce', function (Cache $cache, Registry $register, $pools) {
|
Server::setResource('reduce', function (Cache $cache, Registry $register, $pools) {
|
||||||
return function ($database, $projectInternalId, Document $document, array &$metrics) use ($pools, $cache, $register): void {
|
return function ($database, $projectInternalId, Document $document, array &$metrics) use ($pools, $cache, $register): void {
|
||||||
|
|
Loading…
Reference in a new issue