Merge branch 'refactor-usage-sn' of github.com:appwrite/appwrite into remove-cloud-scripts

This commit is contained in:
shimon
2024-02-19 17:38:13 +02:00
4 changed files with 7 additions and 4 deletions
+1
View File
@@ -365,6 +365,7 @@ class Mail extends Event
$client = new Client($this->queue, $this->connection);
return $client->enqueue([
'project' => $this->project,
'recipient' => $this->recipient,
'name' => $this->name,
'subject' => $this->subject,
+1
View File
@@ -76,6 +76,7 @@ class Usage extends Action
}
$this->stats[$projectId]['project'] = $project;
$this->stats[$projectId]['receivedAt'] = DateTime::now();
foreach ($payload['metrics'] ?? [] as $metric) {
$this->keys++;
if (!isset($this->stats[$projectId]['keys'][$metric['key']])) {
+2 -2
View File
@@ -59,12 +59,12 @@ class UsageDump extends Action
foreach ($payload['stats'] ?? [] as $stats) {
$project = new Document($stats['project'] ?? []);
$numberOfKeys = !empty($stats['keys']) ? count($stats['keys']) : 0;
$receivedAt = $stats['receivedAt'] ?? 'NONE';
if ($numberOfKeys === 0) {
continue;
}
console::log('[' . DateTime::now() . '] ProjectId [' . $project->getInternalId() . '] Database [' . $project['database'] . '] ' . $numberOfKeys . ' keys');
console::log('[' . DateTime::now() . '] ProjectId [' . $project->getInternalId() . '] ReceivedAt [' . $receivedAt . '] ' . $numberOfKeys . ' keys');
try {
$dbForProject = $getProjectDB($project);