Feature: CronJob for refreshing materialized view association between address and geographical unit

This commit is contained in:
Julien Fastré 2022-12-12 21:17:03 +01:00
parent 204ebd4415
commit 7d469df62a
Signed by: julienfastre
GPG Key ID: BDE2190974723FCB

View File

@ -32,14 +32,14 @@ class RefreshAddressToGeographicalUnitMaterializedViewCronJob implements CronJob
public function canRun(?CronJobExecution $cronJobExecution): bool
{
if ($cronJobExecution->getKey() !== $this->getKey()) {
throw new UnexpectedValueException();
}
if (null === $cronJobExecution) {
return true;
}
if ($cronJobExecution->getKey() !== $this->getKey()) {
throw new UnexpectedValueException();
}
$now = new DateTimeImmutable('now');
return $cronJobExecution->getLastStart() < $now->sub(new DateInterval('P1D'))