AzuraCast/src/Sync/Task/CleanupRelaysTask.php

27 lines
632 B
PHP
Raw Normal View History

2019-07-16 00:04:34 +00:00
<?php
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
{
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.
$threshold = time() - 90;
2019-07-16 00:04:34 +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();
}
}