mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Use disable instead of skip agin
This commit is contained in:
parent
61c619f373
commit
08f30224b6
1 changed files with 78 additions and 79 deletions
|
|
@ -77,7 +77,7 @@ class StatsResources extends Action
|
||||||
$this->documents = [];
|
$this->documents = [];
|
||||||
|
|
||||||
$startTime = microtime(true);
|
$startTime = microtime(true);
|
||||||
$dbForPlatform->skipFilters(fn () => $this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project));
|
$this->countForProject($dbForPlatform, $getLogsDB, $getProjectDB, $project);
|
||||||
$endTime = microtime(true);
|
$endTime = microtime(true);
|
||||||
$executionTime = $endTime - $startTime;
|
$executionTime = $endTime - $startTime;
|
||||||
Console::info('Project: ' . $project->getId() . '(' . $project->getSequence() . ') aggregated in ' . $executionTime .' seconds');
|
Console::info('Project: ' . $project->getId() . '(' . $project->getSequence() . ') aggregated in ' . $executionTime .' seconds');
|
||||||
|
|
@ -99,7 +99,9 @@ class StatsResources extends Action
|
||||||
Console::error($th->getMessage());
|
Console::error($th->getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dbForPlatform->disableFilters();
|
||||||
|
$dbForProject->disableFilters();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$region = $project->getAttribute('region');
|
$region = $project->getAttribute('region');
|
||||||
|
|
@ -120,91 +122,88 @@ class StatsResources extends Action
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
$dbForProject->skipFilters(function () use ($dbForProject, $dbForLogs, $region, $project, $platforms, $webhooks, $keys, $domains) {
|
$databases = $dbForProject->count('databases');
|
||||||
$databases = $dbForProject->count('databases');
|
$buckets = $dbForProject->count('buckets');
|
||||||
$buckets = $dbForProject->count('buckets');
|
$users = $dbForProject->count('users');
|
||||||
$users = $dbForProject->count('users');
|
|
||||||
|
|
||||||
$last30Days = (new \DateTime())->sub(\DateInterval::createFromDateString('30 days'))->format('Y-m-d 00:00:00');
|
$last30Days = (new \DateTime())->sub(\DateInterval::createFromDateString('30 days'))->format('Y-m-d 00:00:00');
|
||||||
$usersMAU = $dbForProject->count('users', [
|
$usersMAU = $dbForProject->count('users', [
|
||||||
Query::greaterThanEqual('accessedAt', $last30Days)
|
Query::greaterThanEqual('accessedAt', $last30Days)
|
||||||
]);
|
]);
|
||||||
$last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours'))->format('Y-m-d h:m:00');
|
$last24Hours = (new \DateTime())->sub(\DateInterval::createFromDateString('24 hours'))->format('Y-m-d h:m:00');
|
||||||
$usersDAU = $dbForProject->count('users', [
|
$usersDAU = $dbForProject->count('users', [
|
||||||
Query::greaterThanEqual('accessedAt', $last24Hours)
|
Query::greaterThanEqual('accessedAt', $last24Hours)
|
||||||
]);
|
]);
|
||||||
$last7Days = (new \DateTime())->sub(\DateInterval::createFromDateString('7 days'))->format('Y-m-d 00:00:00');
|
$last7Days = (new \DateTime())->sub(\DateInterval::createFromDateString('7 days'))->format('Y-m-d 00:00:00');
|
||||||
$usersWAU = $dbForProject->count('users', [
|
$usersWAU = $dbForProject->count('users', [
|
||||||
Query::greaterThanEqual('accessedAt', $last7Days)
|
Query::greaterThanEqual('accessedAt', $last7Days)
|
||||||
]);
|
]);
|
||||||
$teams = $dbForProject->count('teams');
|
$teams = $dbForProject->count('teams');
|
||||||
$functions = $dbForProject->count('functions');
|
$functions = $dbForProject->count('functions');
|
||||||
|
|
||||||
$messages = $dbForProject->count('messages');
|
$messages = $dbForProject->count('messages');
|
||||||
$providers = $dbForProject->count('providers');
|
$providers = $dbForProject->count('providers');
|
||||||
$topics = $dbForProject->count('topics');
|
$topics = $dbForProject->count('topics');
|
||||||
$targets = $dbForProject->count('targets');
|
$targets = $dbForProject->count('targets');
|
||||||
$emailTargets = $dbForProject->count('targets', [
|
$emailTargets = $dbForProject->count('targets', [
|
||||||
Query::equal('providerType', [MESSAGE_TYPE_EMAIL])
|
Query::equal('providerType', [MESSAGE_TYPE_EMAIL])
|
||||||
]);
|
]);
|
||||||
$pushTargets = $dbForProject->count('targets', [
|
$pushTargets = $dbForProject->count('targets', [
|
||||||
Query::equal('providerType', [MESSAGE_TYPE_PUSH])
|
Query::equal('providerType', [MESSAGE_TYPE_PUSH])
|
||||||
]);
|
]);
|
||||||
$smsTargets = $dbForProject->count('targets', [
|
$smsTargets = $dbForProject->count('targets', [
|
||||||
Query::equal('providerType', [MESSAGE_TYPE_SMS])
|
Query::equal('providerType', [MESSAGE_TYPE_SMS])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$metrics = [
|
$metrics = [
|
||||||
METRIC_DATABASES => $databases,
|
METRIC_DATABASES => $databases,
|
||||||
METRIC_BUCKETS => $buckets,
|
METRIC_BUCKETS => $buckets,
|
||||||
METRIC_USERS => $users,
|
METRIC_USERS => $users,
|
||||||
METRIC_FUNCTIONS => $functions,
|
METRIC_FUNCTIONS => $functions,
|
||||||
METRIC_TEAMS => $teams,
|
METRIC_TEAMS => $teams,
|
||||||
METRIC_MESSAGES => $messages,
|
METRIC_MESSAGES => $messages,
|
||||||
METRIC_MAU => $usersMAU,
|
METRIC_MAU => $usersMAU,
|
||||||
METRIC_DAU => $usersDAU,
|
METRIC_DAU => $usersDAU,
|
||||||
METRIC_WAU => $usersWAU,
|
METRIC_WAU => $usersWAU,
|
||||||
METRIC_WEBHOOKS => $webhooks,
|
METRIC_WEBHOOKS => $webhooks,
|
||||||
METRIC_PLATFORMS => $platforms,
|
METRIC_PLATFORMS => $platforms,
|
||||||
METRIC_PROVIDERS => $providers,
|
METRIC_PROVIDERS => $providers,
|
||||||
METRIC_TOPICS => $topics,
|
METRIC_TOPICS => $topics,
|
||||||
METRIC_KEYS => $keys,
|
METRIC_KEYS => $keys,
|
||||||
METRIC_DOMAINS => $domains,
|
METRIC_DOMAINS => $domains,
|
||||||
METRIC_TARGETS => $targets,
|
METRIC_TARGETS => $targets,
|
||||||
str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets,
|
str_replace('{providerType}', MESSAGE_TYPE_EMAIL, METRIC_PROVIDER_TYPE_TARGETS) => $emailTargets,
|
||||||
str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets,
|
str_replace('{providerType}', MESSAGE_TYPE_PUSH, METRIC_PROVIDER_TYPE_TARGETS) => $pushTargets,
|
||||||
str_replace('{providerType}', MESSAGE_TYPE_SMS, METRIC_PROVIDER_TYPE_TARGETS) => $smsTargets,
|
str_replace('{providerType}', MESSAGE_TYPE_SMS, METRIC_PROVIDER_TYPE_TARGETS) => $smsTargets,
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach ($metrics as $metric => $value) {
|
foreach ($metrics as $metric => $value) {
|
||||||
$this->createStatsDocuments($region, $metric, $value);
|
$this->createStatsDocuments($region, $metric, $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->countForBuckets($dbForProject, $dbForLogs, $region);
|
$this->countForBuckets($dbForProject, $dbForLogs, $region);
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]);
|
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->countImageTransformations($dbForProject, $dbForLogs, $region);
|
$this->countImageTransformations($dbForProject, $dbForLogs, $region);
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]);
|
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_buckets_{$project->getId()}"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->countForDatabase($dbForProject, $region);
|
$this->countForDatabase($dbForProject, $region);
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]);
|
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_database_{$project->getId()}"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
$this->countForSitesAndFunctions($dbForProject, $region);
|
|
||||||
} catch (Throwable $th) {
|
|
||||||
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
$this->countForSitesAndFunctions($dbForProject, $region);
|
||||||
|
} catch (Throwable $th) {
|
||||||
|
call_user_func_array($this->logError, [$th, "StatsResources", "count_for_functions_{$project->getId()}"]);
|
||||||
|
}
|
||||||
|
|
||||||
$this->writeDocuments($dbForLogs, $project);
|
$this->writeDocuments($dbForLogs, $project);
|
||||||
} catch (Throwable $th) {
|
} catch (Throwable $th) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue