mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
chore: review comments
This commit is contained in:
parent
48525ce755
commit
294f6818fa
1 changed files with 9 additions and 18 deletions
|
|
@ -113,25 +113,16 @@ class Audits extends Action
|
||||||
Console::log('Processing batch with ' . count(self::$logs) . ' events');
|
Console::log('Processing batch with ' . count(self::$logs) . ' events');
|
||||||
|
|
||||||
$audit = new Audit($dbForProject);
|
$audit = new Audit($dbForProject);
|
||||||
$batchEvents = array_map(function ($event) {
|
|
||||||
return [
|
|
||||||
'userId' => $event['userId'],
|
|
||||||
'event' => $event['event'],
|
|
||||||
'resource' => $event['resource'],
|
|
||||||
'userAgent' => $event['userAgent'],
|
|
||||||
'ip' => $event['ip'],
|
|
||||||
'location' => $event['location'],
|
|
||||||
'data' => $event['data'],
|
|
||||||
'timestamp' => $event['timestamp']
|
|
||||||
];
|
|
||||||
}, self::$logs);
|
|
||||||
|
|
||||||
$audit->logBatch($batchEvents);
|
try {
|
||||||
|
$audit->logBatch(self::$logs);
|
||||||
// Clear the pending events after successful batch processing
|
Console::success('Audit logs processed successfully');
|
||||||
self::$logs = [];
|
} catch (Throwable $e) {
|
||||||
|
Console::error('Error processing audit logs: ' . $e->getMessage());
|
||||||
Console::success('Audit logs processed successfully');
|
} finally {
|
||||||
|
// Clear the pending events after successful batch processing
|
||||||
|
self::$logs = [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue