chore: add console audit retention

This commit is contained in:
Chirag Aggarwal
2025-03-20 10:32:36 +00:00
parent 9345025ade
commit 5eb7c36f50
4 changed files with 11 additions and 3 deletions
+1 -1
View File
@@ -85,7 +85,7 @@ _APP_MAINTENANCE_DELAY=
_APP_MAINTENANCE_RETENTION_CACHE=2592000
_APP_MAINTENANCE_RETENTION_EXECUTION=1209600
_APP_MAINTENANCE_RETENTION_ABUSE=86400
_APP_MAINTENANCE_RETENTION_AUDIT=1209600
_APP_MAINTENANCE_RETENTION_AUDIT=project=1209600,console=15778800
_APP_USAGE_AGGREGATION_INTERVAL=30
_APP_STATS_RESOURCES_INTERVAL=3600
_APP_MAINTENANCE_RETENTION_USAGE_HOURLY=8640000
+1 -1
View File
@@ -219,7 +219,7 @@ Server::setResource('abuseRetention', function () {
});
Server::setResource('auditRetention', function () {
return DateTime::addSeconds(new \DateTime(), -1 * System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 1209600));
return System::getEnv('_APP_MAINTENANCE_RETENTION_AUDIT', 'project=1209600,console=15778800'); // project = 14 days, console = 6 months
});
Server::setResource('executionRetention', function () {
+1
View File
@@ -389,6 +389,7 @@ services:
- _APP_DATABASE_SHARED_TABLES
- _APP_DATABASE_SHARED_TABLES_V1
- _APP_EMAIL_CERTIFICATES
- _APP_MAINTENANCE_RETENTION_AUDIT
appwrite-worker-databases:
entrypoint: worker-databases
+8 -1
View File
@@ -751,9 +751,16 @@ class Deletes extends Action
$projectId = $project->getId();
$dbForProject = $getProjectDB($project);
[$projectAuditRetention, $consoleAuditRetention] = array_map(
function ($part) {
return DateTime::addSeconds(new \DateTime(), -1 * (int)explode('=', $part)[1]);
},
explode(',', $auditRetention)
);
try {
$this->deleteByGroup(Audit::COLLECTION, [
Query::lessThan('time', $auditRetention),
Query::lessThan('time', ($projectId === 'console' ? $consoleAuditRetention : $projectAuditRetention)),
Query::orderDesc('time'),
Query::orderDesc('$internalId'),
], $dbForProject);