feat: upgrade hamster script
This commit is contained in:
parent
2dda3a02f2
commit
66daa80c07
|
@ -19,12 +19,17 @@ use Utopia\Registry\Registry;
|
||||||
class Hamster extends Action
|
class Hamster extends Action
|
||||||
{
|
{
|
||||||
private array $columns = [
|
private array $columns = [
|
||||||
|
'Timestamp',
|
||||||
'Project ID',
|
'Project ID',
|
||||||
'Project Name',
|
'Project Name',
|
||||||
'Functions',
|
'Functions',
|
||||||
'Deployments',
|
'Deployments',
|
||||||
'Members',
|
'Members',
|
||||||
'Domains',
|
'Domains',
|
||||||
|
'Platforms - Web',
|
||||||
|
'Platforms - Android',
|
||||||
|
'Platforms - iOS',
|
||||||
|
'Platforms - Flutter',
|
||||||
'Files',
|
'Files',
|
||||||
'Buckets',
|
'Buckets',
|
||||||
'Databases',
|
'Databases',
|
||||||
|
@ -79,6 +84,9 @@ class Hamster extends Action
|
||||||
{
|
{
|
||||||
$stats = [];
|
$stats = [];
|
||||||
|
|
||||||
|
/** Set the timestamp in ISO 8601 format */
|
||||||
|
$stats['Timestamp'] = \date('c');
|
||||||
|
|
||||||
/** Get Project ID */
|
/** Get Project ID */
|
||||||
$stats['Project ID'] = $project->getId();
|
$stats['Project ID'] = $project->getId();
|
||||||
|
|
||||||
|
@ -104,6 +112,28 @@ class Hamster extends Action
|
||||||
/** Get Domains */
|
/** Get Domains */
|
||||||
$stats['Domains'] = $dbForProject->count('domains', [], APP_LIMIT_COUNT);
|
$stats['Domains'] = $dbForProject->count('domains', [], APP_LIMIT_COUNT);
|
||||||
|
|
||||||
|
/** Get Platforms */
|
||||||
|
$platforms = $dbForConsole->find('platforms', [
|
||||||
|
Query::equal('projectInternalId', [$project->getInternalId()]),
|
||||||
|
Query::limit(100)
|
||||||
|
]);
|
||||||
|
|
||||||
|
$stats['Platforms - Web'] = array_count_values(array_filter($platforms, function ($platform) {
|
||||||
|
return $platform['platform'] === 'web';
|
||||||
|
}));
|
||||||
|
|
||||||
|
$stats['Platforms - Android'] = array_count_values(array_filter($platforms, function ($platform) {
|
||||||
|
return $platform['platform'] === 'android';
|
||||||
|
}));
|
||||||
|
|
||||||
|
$stats['Platforms - iOS'] = array_count_values(array_filter($platforms, function ($platform) {
|
||||||
|
return str_contains($platform['platform'], 'apple');
|
||||||
|
}));
|
||||||
|
|
||||||
|
$stats['Platforms - Flutter'] = array_count_values(array_filter($platforms, function ($platform) {
|
||||||
|
return str_contains($platform['platform'],'flutter');
|
||||||
|
}));
|
||||||
|
|
||||||
/** Get Usage stats */
|
/** Get Usage stats */
|
||||||
$range = '90d';
|
$range = '90d';
|
||||||
$periods = [
|
$periods = [
|
||||||
|
@ -223,7 +253,8 @@ class Hamster extends Action
|
||||||
Console::log('Iterated through ' . $count . '/' . $totalProjects . ' projects...');
|
Console::log('Iterated through ' . $count . '/' . $totalProjects . ' projects...');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sendEmail($register);
|
// var_dump($csv->toString());
|
||||||
|
// $this->sendEmail($register);
|
||||||
|
|
||||||
$pools
|
$pools
|
||||||
->get('console')
|
->get('console')
|
||||||
|
|
Loading…
Reference in a new issue