mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-17 09:45:29 +00:00
feat: add delete property on Event
This commit is contained in:
parent
0b4fc8b061
commit
f36116afa9
@ -1,4 +1,4 @@
|
||||
import {Progress, Timeline, Tooltip, Typography} from "antd";
|
||||
import {Timeline, Tooltip, Typography} from "antd";
|
||||
import React from "react";
|
||||
import {Event} from "../../utils/api";
|
||||
import useBreakpoint from "../../hooks/useBreakpoint";
|
||||
@ -18,14 +18,13 @@ export function EventTimeline({events}: { events: Event[] }) {
|
||||
mode={sm ? "left" : "right"}
|
||||
items={events.map(e => {
|
||||
const sameEvents = events.filter(se => se.action === e.action)
|
||||
const isRelevant = !(sameEvents.length > 1 && sameEvents.indexOf(e) !== 0)
|
||||
|
||||
const eventName = <Typography.Text style={{color: isRelevant ? 'default' : 'grey'}}>
|
||||
const eventName = <Typography.Text style={{color: e.deleted ? 'grey' : 'default'}}>
|
||||
{e.action in rdapEventNameTranslated ? rdapEventNameTranslated[e.action as keyof typeof rdapEventNameTranslated] : e.action}
|
||||
</Typography.Text>
|
||||
|
||||
const dateStr = <Typography.Text
|
||||
style={{color: isRelevant ? 'default' : 'grey'}}>{new Date(e.date).toLocaleString(locale)}
|
||||
style={{color: e.deleted ? 'grey' : 'default'}}>{new Date(e.date).toLocaleString(locale)}
|
||||
</Typography.Text>
|
||||
|
||||
const eventDetail = e.action in rdapEventDetailTranslated ? rdapEventDetailTranslated[e.action as keyof typeof rdapEventDetailTranslated] : undefined
|
||||
@ -40,7 +39,7 @@ export function EventTimeline({events}: { events: Event[] }) {
|
||||
}
|
||||
|
||||
return {
|
||||
color: isRelevant ? actionToColor(e.action) : 'grey',
|
||||
color: e.deleted ? 'grey' : actionToColor(e.action),
|
||||
dot: actionToIcon(e.action),
|
||||
pending: new Date(e.date).getTime() > new Date().getTime(),
|
||||
...text
|
||||
|
||||
@ -21,6 +21,7 @@ export type TriggerAction = 'email' | string
|
||||
export interface Event {
|
||||
action: EventAction
|
||||
date: string
|
||||
deleted: boolean
|
||||
}
|
||||
|
||||
export interface Entity {
|
||||
|
||||
34
migrations/Version20240901190812.php
Normal file
34
migrations/Version20240901190812.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?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 Version20240901190812 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_event ADD deleted BOOLEAN NOT NULL DEFAULT FALSE');
|
||||
$this->addSql('ALTER TABLE entity_event ADD deleted BOOLEAN NOT NULL DEFAULT FALSE');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('CREATE SCHEMA public');
|
||||
$this->addSql('ALTER TABLE domain_event DROP deleted');
|
||||
$this->addSql('ALTER TABLE entity_event DROP deleted');
|
||||
}
|
||||
}
|
||||
@ -25,7 +25,7 @@ class DomainRefreshController extends AbstractController
|
||||
private readonly RDAPService $RDAPService,
|
||||
private readonly RateLimiterFactory $rdapRequestsLimiter,
|
||||
private readonly MessageBusInterface $bus,
|
||||
private readonly LoggerInterface $logger
|
||||
private readonly LoggerInterface $logger, private readonly KernelInterface $kernel
|
||||
) {
|
||||
}
|
||||
|
||||
@ -55,6 +55,7 @@ class DomainRefreshController extends AbstractController
|
||||
&& !$domain->getDeleted()
|
||||
&& ($domain->getUpdatedAt()->diff(new \DateTimeImmutable('now'))->days < 7)
|
||||
&& !$this->RDAPService::isToBeWatchClosely($domain, $domain->getUpdatedAt())
|
||||
&& !$this->kernel->isDebug()
|
||||
) {
|
||||
$this->logger->info('It is not necessary to update the information of the domain name {idnDomain} with the RDAP protocol.', [
|
||||
'idnDomain' => $idnDomain,
|
||||
|
||||
@ -100,9 +100,9 @@ class Domain
|
||||
#[Groups(['domain:item'])]
|
||||
private ?Tld $tld = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[ORM\Column(nullable: false)]
|
||||
#[Groups(['domain:item'])]
|
||||
private ?bool $deleted = null;
|
||||
private ?bool $deleted;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
@ -21,6 +21,15 @@ class Event
|
||||
#[Groups(['event:list'])]
|
||||
private ?\DateTimeImmutable $date = null;
|
||||
|
||||
#[ORM\Column]
|
||||
#[Groups(['event:list'])]
|
||||
private ?bool $deleted;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->deleted = false;
|
||||
}
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@ -49,4 +58,16 @@ class Event
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDeleted(): ?bool
|
||||
{
|
||||
return $this->deleted;
|
||||
}
|
||||
|
||||
public function setDeleted(?bool $deleted): static
|
||||
{
|
||||
$this->deleted = $deleted;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -218,6 +218,11 @@ readonly class RDAPService
|
||||
$this->em->persist($domain);
|
||||
$this->em->flush();
|
||||
|
||||
/** @var DomainEvent $event */
|
||||
foreach ($domain->getEvents()->getIterator() as $event) {
|
||||
$event->setDeleted(true);
|
||||
}
|
||||
|
||||
foreach ($res['events'] as $rdapEvent) {
|
||||
if ($rdapEvent['eventAction'] === EventAction::LastUpdateOfRDAPDatabase->value) {
|
||||
continue;
|
||||
@ -234,7 +239,9 @@ readonly class RDAPService
|
||||
}
|
||||
$domain->addEvent($event
|
||||
->setAction($rdapEvent['eventAction'])
|
||||
->setDate(new \DateTimeImmutable($rdapEvent['eventDate'])));
|
||||
->setDate(new \DateTimeImmutable($rdapEvent['eventDate']))
|
||||
->setDeleted(false)
|
||||
);
|
||||
}
|
||||
|
||||
if (array_key_exists('entities', $res) && is_array($res['entities'])) {
|
||||
@ -399,6 +406,14 @@ readonly class RDAPService
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/** @var EntityEvent $event */
|
||||
foreach ($entity->getEvents()->getIterator() as $event) {
|
||||
$event->setDeleted(true);
|
||||
}
|
||||
|
||||
$this->em->persist($entity);
|
||||
$this->em->flush();
|
||||
|
||||
foreach ($rdapEntity['events'] as $rdapEntityEvent) {
|
||||
$eventAction = $rdapEntityEvent['eventAction'];
|
||||
if ($eventAction === EventAction::LastChanged->value || $eventAction === EventAction::LastUpdateOfRDAPDatabase->value) {
|
||||
@ -410,13 +425,15 @@ readonly class RDAPService
|
||||
]);
|
||||
|
||||
if (null !== $event) {
|
||||
$event->setDeleted(false);
|
||||
continue;
|
||||
}
|
||||
$entity->addEvent(
|
||||
(new EntityEvent())
|
||||
->setEntity($entity)
|
||||
->setAction($rdapEntityEvent['eventAction'])
|
||||
->setDate(new \DateTimeImmutable($rdapEntityEvent['eventDate'])));
|
||||
->setDate(new \DateTimeImmutable($rdapEntityEvent['eventDate']))
|
||||
->setDeleted(false));
|
||||
}
|
||||
|
||||
return $entity;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user