feat: remove outdated log entries scheduled

This commit is contained in:
Björn Fromme
2026-03-16 12:01:09 +01:00
parent 9ee4c1cd5c
commit 645729a518
4 changed files with 108 additions and 1 deletions
+30
View File
@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
namespace App\Repository;
use App\Entity\LogEntry;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<LogEntry>
*/
class LogEntryRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, LogEntry::class);
}
public function deleteOlderThan(\DateTimeImmutable $threshold): int
{
return $this->createQueryBuilder('l')
->delete()
->where('l.createdAt < :threshold')
->setParameter('threshold', $threshold)
->getQuery()
->execute();
}
}