Merge pull request #9487 from appwrite/feat-bulk-audit-delete

Feat bulk audit delete
This commit is contained in:
Jake Barnby 2025-03-13 12:53:57 +13:00 committed by GitHub
commit b0d6ffa582
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -737,10 +737,12 @@ class Deletes extends Action
{
$projectId = $project->getId();
$dbForProject = $getProjectDB($project);
$audit = new Audit($dbForProject);
try {
$audit->cleanup($auditRetention);
$this->deleteByGroup(Audit::COLLECTION, [
Query::lessThan('time', $auditRetention),
Query::orderDesc('time'),
], $dbForProject);
} catch (DatabaseException $e) {
Console::error('Failed to delete audit logs for project ' . $projectId . ': ' . $e->getMessage());
}
@ -948,7 +950,7 @@ class Deletes extends Action
* @param Database $database
* @param ?callable $callback
* @return void
* @throws Exception
* @throws DatabaseException
*/
protected function deleteByGroup(
string $collection,