mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-03-22 05:38:08 +00:00
Add RemoveOldAuditCronJob to clean up outdated audit trails
- Introduced `RemoveOldAuditCronJob` class implementing `CronJobInterface` to delete old audit trails based on configured retention period. - Added `deleteBefore` method to `AuditTrailRepository` to handle removal of records older than the specified date. - Created `RemoveOldAuditCronJobTest` to ensure correct functionality for job execution and canRun logic. - Updated DI configuration to include the `delete_after` parameter for audit trail retention settings.
This commit is contained in:
@@ -85,6 +85,15 @@ class AuditTrailRepository extends ServiceEntityRepository
|
||||
->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function deleteBefore(\DateTimeImmutable $date): void
|
||||
{
|
||||
$this->createQueryBuilder('audit')
|
||||
->delete()
|
||||
->where('audit.occurredAt < :date')
|
||||
->setParameter('date', $date, Types::DATETIMETZ_IMMUTABLE)
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{subjects?: list<Subject>, from_date?: \DateTimeImmutable, to_date?: \DateTimeImmutable, by_users?: list<User>} $criteria
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user