Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions lib/Db/EventWrapperRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,19 +122,18 @@ public function getByToken(string $token): array {
}

/**
* delete completed entries older than a month
*
* @param bool $allOldEntries delete also not-completed entries
* delete completed entries older than a week,
* delete all entries older than a month
*/
public function deleteOldEntries(bool $allOldEntries = false): void {
public function deleteOldEntries(): void {
$qb = $this->getEventWrapperDeleteSql();
$qb->where(
$qb->exprLimitInt('status', EventWrapper::STATUS_OVER),
$qb->exprLt('creation', time() - 30 * 86400)
);
if (!$allOldEntries) {
$qb->andWhere($qb->exprLimitInt('status', EventWrapper::STATUS_OVER));
}
$qb->where($qb->expr()->orX(
$qb->expr()->andX(
$qb->exprLimitInt('status', EventWrapper::STATUS_OVER),
$qb->exprLt('creation', time() - 604800)
),
$qb->exprLt('creation', time() - (4 * 604800)),
));

$qb->executeStatement();
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/MaintenanceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private function runMaintenance4(bool $forceRefresh = false): void {

try {
$this->output('Delete old and terminated FederatedEvents');
$this->eventWrapperRequest->deleteOldEntries(false);
$this->eventWrapperRequest->deleteOldEntries();
} catch (Exception $e) {
$this->logger->warning('issue while deleting old events', ['exception' => $e]);
}
Expand Down
Loading