From 71173306d6044fbeabad374c5f02c814f0a2e74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Gangloff?= Date: Wed, 4 Sep 2024 18:33:02 +0200 Subject: [PATCH] fix: switch updatedAt to datetime_immutable --- migrations/Version20240904162520.php | 33 +++++++++++++++++++ src/Controller/DomainRefreshController.php | 2 +- src/Entity/Domain.php | 6 ++-- .../UpdateDomainsFromWatchlistHandler.php | 2 +- .../SendNotifWatchListTriggerSchedule.php | 2 +- src/Service/RDAPService.php | 2 +- 6 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 migrations/Version20240904162520.php diff --git a/migrations/Version20240904162520.php b/migrations/Version20240904162520.php new file mode 100644 index 0000000..17539fd --- /dev/null +++ b/migrations/Version20240904162520.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE domain ALTER updated_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('COMMENT ON COLUMN domain.updated_at IS \'(DC2Type:datetime_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE domain ALTER updated_at TYPE DATE'); + $this->addSql('COMMENT ON COLUMN domain.updated_at IS \'(DC2Type:date_immutable)\''); + } +} diff --git a/src/Controller/DomainRefreshController.php b/src/Controller/DomainRefreshController.php index b84bbb0..2b55f0b 100644 --- a/src/Controller/DomainRefreshController.php +++ b/src/Controller/DomainRefreshController.php @@ -54,7 +54,7 @@ class DomainRefreshController extends AbstractController if (null !== $domain && !$domain->getDeleted() && ($domain->getUpdatedAt()->diff(new \DateTimeImmutable('now'))->days < 7) - && !$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt()) + && !$this->RDAPService::isToBeWatchClosely($domain) && !$this->kernel->isDebug() ) { $this->logger->info('It is not necessary to update the information of the domain name {idnDomain} with the RDAP protocol.', [ diff --git a/src/Entity/Domain.php b/src/Entity/Domain.php index 730198b..f69ce7b 100644 --- a/src/Entity/Domain.php +++ b/src/Entity/Domain.php @@ -90,10 +90,10 @@ class Domain private Collection $nameservers; #[ORM\Column(type: Types::DATE_IMMUTABLE)] - private ?\DateTimeImmutable $createdAt = null; + private ?\DateTimeImmutable $createdAt; - #[ORM\Column(type: Types::DATE_IMMUTABLE)] - private ?\DateTimeImmutable $updatedAt = null; + #[ORM\Column(type: Types::DATETIME_IMMUTABLE)] + private ?\DateTimeImmutable $updatedAt; #[ORM\ManyToOne] #[ORM\JoinColumn(referencedColumnName: 'tld', nullable: false)] diff --git a/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php b/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php index 7a0bc86..36dff2d 100644 --- a/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php +++ b/src/MessageHandler/UpdateDomainsFromWatchlistHandler.php @@ -65,7 +65,7 @@ final readonly class UpdateDomainsFromWatchlistHandler ->filter(fn ($domain) => $domain->getUpdatedAt() ->diff( new \DateTimeImmutable('now'))->days >= 7 - || $this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt()) + || $this->RDAPService::isToBeWatchClosely($domain) ) as $domain ) { $updatedAt = $domain->getUpdatedAt(); diff --git a/src/Scheduler/SendNotifWatchListTriggerSchedule.php b/src/Scheduler/SendNotifWatchListTriggerSchedule.php index 87308e5..54c8fdb 100644 --- a/src/Scheduler/SendNotifWatchListTriggerSchedule.php +++ b/src/Scheduler/SendNotifWatchListTriggerSchedule.php @@ -21,7 +21,7 @@ final readonly class SendNotifWatchListTriggerSchedule implements ScheduleProvid { return (new Schedule()) ->add( - RecurringMessage::every('1 day', new ProcessWatchListsTrigger()), + RecurringMessage::every('1 hour', new ProcessWatchListsTrigger()), ) ->stateful($this->cache); } diff --git a/src/Service/RDAPService.php b/src/Service/RDAPService.php index e8691c8..f365847 100644 --- a/src/Service/RDAPService.php +++ b/src/Service/RDAPService.php @@ -99,7 +99,7 @@ readonly class RDAPService * * @throws \Exception */ - public static function isToBeWatchClosely(Domain $domain, \DateTimeImmutable $updatedAt): bool + public static function isToBeWatchClosely(Domain $domain): bool { $status = $domain->getStatus(); if (!empty($status) && count(array_intersect($status, self::IMPORTANT_STATUS))) {