Skip to content

Commit

Permalink
fix: switch updatedAt to datetime_immutable
Browse files Browse the repository at this point in the history
  • Loading branch information
maelgangloff committed Sep 4, 2024
1 parent b4aef61 commit 7117330
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 7 deletions.
33 changes: 33 additions & 0 deletions migrations/Version20240904162520.php
Original file line number Diff line number Diff line change
@@ -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)\'');
}
}
2 changes: 1 addition & 1 deletion src/Controller/DomainRefreshController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function __invoke(string $ldhName, KernelInterface $kernel): Domain
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.', [
Expand Down
6 changes: 3 additions & 3 deletions src/Entity/Domain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion src/MessageHandler/UpdateDomainsFromWatchlistHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function __invoke(UpdateDomainsFromWatchlist $message): void
->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();
Expand Down
2 changes: 1 addition & 1 deletion src/Scheduler/SendNotifWatchListTriggerSchedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function getSchedule(): Schedule
{
return (new Schedule())
->add(
RecurringMessage::every('1 day', new ProcessWatchListsTrigger()),
RecurringMessage::every('1 hour', new ProcessWatchListsTrigger()),
)
->stateful($this->cache);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Service/RDAPService.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function __construct(private HttpClientInterface $client,
*
* @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))) {
Expand Down

0 comments on commit 7117330

Please sign in to comment.