mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
Fix RefreshAddressToGeographicalUnitMaterializedViewCronJobTest: use ClockInterface to handle properly now and use more random tests
This commit is contained in:
@@ -16,12 +16,15 @@ use Chill\MainBundle\Entity\CronJobExecution;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Symfony\Component\Clock\ClockInterface;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJobInterface
|
||||
final readonly class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJobInterface
|
||||
{
|
||||
public function __construct(private readonly Connection $connection)
|
||||
{
|
||||
public function __construct(
|
||||
private Connection $connection,
|
||||
private ClockInterface $clock,
|
||||
) {
|
||||
}
|
||||
|
||||
public function canRun(?CronJobExecution $cronJobExecution): bool
|
||||
@@ -34,7 +37,7 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob
|
||||
throw new UnexpectedValueException();
|
||||
}
|
||||
|
||||
$now = new DateTimeImmutable('now');
|
||||
$now = $this->clock->now();
|
||||
|
||||
return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D'))
|
||||
// introduce a random component to ensure a roll when multiple instances are hosted on same machines
|
||||
|
Reference in New Issue
Block a user