users addition
This commit is contained in:
parent
702c92fb5d
commit
48bf74b881
|
@ -23,6 +23,7 @@ class CalcTierStats extends Action
|
||||||
'Organization ID',
|
'Organization ID',
|
||||||
'Organization Members',
|
'Organization Members',
|
||||||
'Teams',
|
'Teams',
|
||||||
|
'Users',
|
||||||
'Requests',
|
'Requests',
|
||||||
'Bandwidth',
|
'Bandwidth',
|
||||||
'Domains',
|
'Domains',
|
||||||
|
@ -124,17 +125,6 @@ class CalcTierStats extends Action
|
||||||
/** Get Project ID */
|
/** Get Project ID */
|
||||||
$stats['Project ID'] = $project->getId();
|
$stats['Project ID'] = $project->getId();
|
||||||
|
|
||||||
///** Get Project Name */
|
|
||||||
//$stats['Project Name'] = $project->getAttribute('name');
|
|
||||||
|
|
||||||
/** Get Organization Name and Id */
|
|
||||||
//$teamId = $project->getAttribute('teamId', null);
|
|
||||||
//$teamName = null;
|
|
||||||
//if ($teamId) {
|
|
||||||
//$team = $dbForConsole->getDocument('teams', $teamId);
|
|
||||||
//$teamName = $team->getAttribute('name');
|
|
||||||
// }
|
|
||||||
|
|
||||||
$stats['Organization ID'] = $project->getAttribute('teamId', null);
|
$stats['Organization ID'] = $project->getAttribute('teamId', null);
|
||||||
|
|
||||||
/** Get Total Members */
|
/** Get Total Members */
|
||||||
|
@ -144,11 +134,22 @@ class CalcTierStats extends Action
|
||||||
Query::equal('teamInternalId', [$teamInternalId])
|
Query::equal('teamInternalId', [$teamInternalId])
|
||||||
]);
|
]);
|
||||||
} else {
|
} else {
|
||||||
$stats['Users'] = 0;
|
$stats['Organization Members'] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Total internal Teams */
|
/** Get Total internal Teams */
|
||||||
$stats['Teams'] = $dbForProject->count('teams', []);
|
try {
|
||||||
|
$stats['Teams'] = $dbForProject->count('teams', []);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Teams'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Get Total users */
|
||||||
|
try {
|
||||||
|
$stats['Users'] = $dbForProject->count('users', []);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Users'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Usage stats */
|
/** Get Usage stats */
|
||||||
$range = '90d';
|
$range = '90d';
|
||||||
|
@ -194,65 +195,101 @@ class CalcTierStats extends Action
|
||||||
$stats[$metrics[$key]] = $value;
|
$stats[$metrics[$key]] = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get Domains */
|
try {
|
||||||
$stats['Domains'] = $dbForConsole->count('domains', [
|
/** Get Domains */
|
||||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
$stats['Domains'] = $dbForConsole->count('domains', [
|
||||||
]);
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||||
|
]);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Domains'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
/** Get Api keys */
|
/** Get Api keys */
|
||||||
$stats['Api keys'] = $dbForConsole->count('keys', [
|
$stats['Api keys'] = $dbForConsole->count('keys', [
|
||||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||||
]);
|
]);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Api keys'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
/** Get Webhooks */
|
/** Get Webhooks */
|
||||||
$stats['Webhooks'] = $dbForConsole->count('webhooks', [
|
$stats['Webhooks'] = $dbForConsole->count('webhooks', [
|
||||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||||
]);
|
]);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Webhooks'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
/** Get Platforms */
|
/** Get Platforms */
|
||||||
$stats['Platforms'] = $dbForConsole->count('platforms', [
|
$stats['Platforms'] = $dbForConsole->count('platforms', [
|
||||||
Query::equal('projectInternalId', [$project->getInternalId()]),
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||||
]);
|
]);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Platforms'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Files & Buckets */
|
/** Get Files & Buckets */
|
||||||
$filesCount = 0;
|
$filesCount = 0;
|
||||||
$filesSum = 0;
|
$filesSum = 0;
|
||||||
$maxFileSize = 0;
|
$maxFileSize = 0;
|
||||||
$buckets = $dbForProject->find('buckets', []);
|
|
||||||
$counter = 0;
|
$counter = 0;
|
||||||
foreach ($buckets as $bucket) {
|
try {
|
||||||
$file = $dbForProject->findOne('bucket_' . $bucket->getInternalId(), [Query::orderDesc('sizeOriginal'),]);
|
$buckets = $dbForProject->find('buckets', []);
|
||||||
if (empty($file)) {
|
foreach ($buckets as $bucket) {
|
||||||
continue;
|
$file = $dbForProject->findOne('bucket_' . $bucket->getInternalId(), [Query::orderDesc('sizeOriginal'),]);
|
||||||
|
if (empty($file)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$filesSum += $dbForProject->sum('bucket_' . $bucket->getInternalId(), 'sizeOriginal', [], 0);
|
||||||
|
$filesCount += $dbForProject->count('bucket_' . $bucket->getInternalId(), []);
|
||||||
|
if ($file->getAttribute('sizeOriginal') > $maxFileSize) {
|
||||||
|
$maxFileSize = $file->getAttribute('sizeOriginal');
|
||||||
|
}
|
||||||
|
$counter++;
|
||||||
}
|
}
|
||||||
$filesSum += $dbForProject->sum('bucket_' . $bucket->getInternalId(), 'sizeOriginal', [], 0);
|
} catch (\Throwable) {
|
||||||
$filesCount += $dbForProject->count('bucket_' . $bucket->getInternalId(), []);
|
;
|
||||||
if ($file->getAttribute('sizeOriginal') > $maxFileSize) {
|
|
||||||
$maxFileSize = $file->getAttribute('sizeOriginal');
|
|
||||||
}
|
|
||||||
$counter++;
|
|
||||||
}
|
}
|
||||||
$stats['Buckets'] = $counter;
|
$stats['Buckets'] = $counter;
|
||||||
$stats['Files'] = $filesCount;
|
$stats['Files'] = $filesCount;
|
||||||
$stats['Storage (bytes)'] = $filesSum;
|
$stats['Storage (bytes)'] = $filesSum;
|
||||||
$stats['Max File Size (bytes)'] = $maxFileSize;
|
$stats['Max File Size (bytes)'] = $maxFileSize;
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
/** Get Total Functions */
|
/** Get Total Functions */
|
||||||
$stats['Databases'] = $dbForProject->count('databases', []);
|
$stats['Databases'] = $dbForProject->count('databases', []);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Databases'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Total Functions */
|
/** Get Total Functions */
|
||||||
$stats['Functions'] = $dbForProject->count('functions', []);
|
try {
|
||||||
|
$stats['Functions'] = $dbForProject->count('functions', []);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Functions'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Total Deployments */
|
/** Get Total Deployments */
|
||||||
$stats['Deployments'] = $dbForProject->count('deployments', []);
|
try {
|
||||||
|
$stats['Deployments'] = $dbForProject->count('deployments', []);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Deployments'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Get Total Executions */
|
/** Get Total Executions */
|
||||||
$stats['Executions'] = $dbForProject->count('executions', []);
|
try {
|
||||||
|
$stats['Executions'] = $dbForProject->count('executions', []);
|
||||||
|
} catch (\Throwable) {
|
||||||
|
$stats['Executions'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$csv->insertOne(array_values($stats));
|
$csv->insertOne(array_values($stats));
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
Console::error('Failed on project ("' . $project->getId() . '") version with error on line no: ' . $th->getline() . 'with message: ' . $th->getMessage());
|
Console::error('Failed on project ("' . $project->getId() . '") version with error on File: ' . $th->getFile() . ' line no: ' . $th->getline() . ' with message: ' . $th->getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
$pools
|
$pools
|
||||||
->get($db)
|
->get($db)
|
||||||
|
|
Loading…
Reference in a new issue