1
0
Fork 0
mirror of synced 2024-05-20 20:52:36 +12:00

Added code packages to storage calculation

This commit is contained in:
Eldad Fux 2020-07-17 12:48:43 +03:00
parent eec1dd6714
commit d115e93a42
2 changed files with 16 additions and 1 deletions

View file

@ -310,10 +310,19 @@ App::get('/v1/projects/:projectId/usage')
'storage' => [
'total' => $projectDB->getCount(
[
'attribute' => 'sizeOriginal',
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_FILES,
],
]
) +
$projectDB->getCount(
[
'attribute' => 'codeSize',
'filters' => [
'$collection='.Database::SYSTEM_COLLECTION_TAGS,
],
]
),
],
]);

View file

@ -657,6 +657,11 @@ class MySQL extends Adapter
$where = [];
$join = [];
$options = array_merge([
'attribute' => '',
'filters' => [],
], $options);
// Filters
foreach ($options['filters'] as $i => $filter) {
$filter = $this->parseFilter($filter);
@ -699,9 +704,10 @@ class MySQL extends Adapter
$where = \implode("\n", $where);
$join = \implode("\n", $join);
$attribute = $this->getPDO()->quote($options['attribute'], PDO::PARAM_STR);
$func = 'JOIN `'.$this->getNamespace().".database.properties` b_func ON a.uid IS NOT NULL
AND a.uid = b_func.documentUid
AND (b_func.key = 'sizeOriginal')";
AND (b_func.key = {$attribute})";
$roles = [];
foreach (Authorization::getRoles() as $role) {