1
0
Fork 0
mirror of synced 2024-06-29 19:50:26 +12:00

interval update

This commit is contained in:
shimon 2024-02-08 21:08:29 +02:00
parent 72ee7d7f34
commit a1539395c6
2 changed files with 5 additions and 3 deletions

View file

@ -90,7 +90,8 @@ class Usage extends Action
$this->keys >= self::KEYS_THRESHOLD ||
(time() - $this->lastTriggeredTime > $aggregationInterval && $this->keys > 0)
) {
var_dump(DateTime::now());
console::warning('[' . DateTime::now() . '] stats aggregation sent to worker with ' . $this->keys . ' keys');
$queueForUsageDump
->setStats($this->stats)
->trigger();

View file

@ -59,12 +59,13 @@ class UsageDump extends Action
foreach ($payload['stats'] ?? [] as $stats) {
$project = new Document($stats['project'] ?? []);
$numberOfKeys = !empty($stats['keys']) ? count($stats['keys']) : 0;
$projectInternalId = $project->getInternalId();
if ($numberOfKeys === 0) {
continue;
}
console::warning('[' . DateTime::now() . '] aggregation received project [' . $project->getInternalId() . '] database [' . $project['database'] . '] ' . $numberOfKeys . ' keys');
try {
$dbForProject = $getProjectDB($project);
foreach ($stats['keys'] ?? [] as $key => $value) {
@ -105,7 +106,7 @@ class UsageDump extends Action
}
}
} catch (\Exception $e) {
console::error(DateTime::now() . ' ' . $projectInternalId . ' ' . $e->getMessage());
console::error('[' . DateTime::now() . '] project [' . $project->getInternalId() . '] database [' . $project['database'] . '] ' . ' ' . $e->getMessage());
}
}
}