2019-07-16 00:04:34 +00:00
|
|
|
<?php
|
2020-10-14 22:19:31 +00:00
|
|
|
|
2021-07-19 05:53:45 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2019-07-16 00:04:34 +00:00
|
|
|
namespace App\Sync\Task;
|
|
|
|
|
2022-07-01 07:41:04 +00:00
|
|
|
final class CleanupRelaysTask extends AbstractTask
|
2019-07-16 00:04:34 +00:00
|
|
|
{
|
2022-01-04 22:46:49 +00:00
|
|
|
public static function getSchedulePattern(): string
|
|
|
|
{
|
|
|
|
return self::SCHEDULE_EVERY_MINUTE;
|
|
|
|
}
|
|
|
|
|
2020-07-08 07:03:50 +00:00
|
|
|
public function run(bool $force = false): void
|
2019-07-16 00:04:34 +00:00
|
|
|
{
|
|
|
|
// Relays should update every 15 seconds, so be fairly aggressive with this.
|
2019-08-12 05:03:00 +00:00
|
|
|
$threshold = time() - 90;
|
2019-07-16 00:04:34 +00:00
|
|
|
|
2020-12-02 00:36:09 +00:00
|
|
|
$this->em->createQuery(
|
|
|
|
<<<'DQL'
|
|
|
|
DELETE FROM App\Entity\Relay r WHERE r.updated_at < :threshold
|
|
|
|
DQL
|
|
|
|
)->setParameter('threshold', $threshold)
|
2019-07-16 00:04:34 +00:00
|
|
|
->execute();
|
|
|
|
}
|
|
|
|
}
|