fix: switch updatedAt to datetime_immutable

This commit is contained in:
Maël Gangloff 2024-09-04 18:33:02 +02:00
parent b4aef61de2
commit 71173306d6
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
6 changed files with 40 additions and 7 deletions

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20240904162520 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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)\'');
}
}

View File

@ -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.', [

View File

@ -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)]

View File

@ -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();

View File

@ -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);
}

View File

@ -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))) {