Merge pull request #10469 from appwrite/stats-resources-try-catch

Stats resources try catch
This commit is contained in:
Jake Barnby 2025-09-10 21:42:29 +12:00 committed by GitHub
commit 27cc649376
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -432,11 +432,20 @@ class StatsResources extends Action
protected function writeDocuments(Database $dbForLogs, Document $project): void
{
$dbForLogs->createOrUpdateDocuments(
'stats',
$this->documents
);
$this->documents = [];
Console::success('Stats written to logs db for project: ' . $project->getId() . '(' . $project->getSequence() . ')');
$message = 'Stats writeDocuments project: ' . $project->getId() . '(' . $project->getSequence() . ')';
try {
$dbForLogs->createOrUpdateDocuments(
'stats',
$this->documents
);
Console::success($message . ' | Documents: ' . count($this->documents));
} catch (\Throwable $e) {
Console::error('Error: ' . $message . ' | Exception: ' . $e->getMessage());
throw $e;
} finally {
$this->documents = [];
}
}
}