mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Deletes 1d 365 days
This commit is contained in:
@@ -398,6 +398,8 @@ class Deletes extends Action
|
||||
/** @var Database $dbForProject*/
|
||||
$dbForProject = $getProjectDB($project);
|
||||
|
||||
$retention1d = DateTime::addSeconds(new \DateTime(), -1 * 365 * 24 * 60 * 60); // 1 year
|
||||
|
||||
$selects = [...$this->selects, 'time'];
|
||||
|
||||
// Delete Usage stats from projectDB
|
||||
@@ -409,6 +411,14 @@ class Deletes extends Action
|
||||
Query::orderDesc(),
|
||||
], $dbForProject);
|
||||
|
||||
$this->deleteByGroup('stats', [
|
||||
Query::select($selects),
|
||||
Query::equal('period', ['1d']),
|
||||
Query::lessThan('time', $retention1d),
|
||||
Query::orderDesc('time'),
|
||||
Query::orderDesc(),
|
||||
], $dbForProject);
|
||||
|
||||
if ($project->getId() !== 'console') {
|
||||
/** @var Database $dbForLogs*/
|
||||
$dbForLogs = call_user_func($getLogsDB, $project);
|
||||
@@ -421,6 +431,14 @@ class Deletes extends Action
|
||||
Query::orderDesc('time'),
|
||||
Query::orderDesc(),
|
||||
], $dbForLogs);
|
||||
|
||||
$this->deleteByGroup('stats', [
|
||||
Query::select($selects),
|
||||
Query::equal('period', ['1d']),
|
||||
Query::lessThan('time', $retention1d),
|
||||
Query::orderDesc('time'),
|
||||
Query::orderDesc(),
|
||||
], $dbForLogs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user