fix: intensify on last day

This commit is contained in:
Maël Gangloff 2025-04-06 15:25:38 +02:00
parent 2a47d351b8
commit c940fba01a
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
5 changed files with 10 additions and 13 deletions

View File

@ -7,16 +7,13 @@ import type {Event} from "../api"
import {t} from "ttag" import {t} from "ttag"
export function DomainToTag({domain}: { domain: { ldhName: string, deleted: boolean, status: string[], events?: Event[] } }) { export function DomainToTag({domain}: { domain: { ldhName: string, deleted: boolean, status: string[], events?: Event[] } }) {
const lastChangedEvent = domain.events?.find(e =>
e.action === 'last changed' &&
!e.deleted &&
((new Date().getTime() - new Date(e.date).getTime()) < 7*24*60*60*1e3)
)
return ( return (
<Link to={'/search/domain/' + domain.ldhName}> <Link to={'/search/domain/' + domain.ldhName}>
<Badge dot={lastChangedEvent !== undefined} color='blue' title={t`The domain name was updated less than a week ago.`}> <Badge dot={domain.events?.find(e =>
e.action === 'last changed' &&
!e.deleted &&
((new Date().getTime() - new Date(e.date).getTime()) < 7*24*60*60*1e3)
) !== undefined} color='blue' title={t`The domain name was updated less than a week ago.`}>
<Tag <Tag
color={ color={
domain.deleted domain.deleted

View File

@ -48,7 +48,7 @@ class RegisterDomainCommand extends Command
try { try {
if (null !== $domain && !$force) { if (null !== $domain && !$force) {
if (!$domain->isToBeUpdated()) { if (!$domain->isToBeUpdated(true, true)) {
$io->warning('The domain name is already present in the database and does not need to be updated at this time.'); $io->warning('The domain name is already present in the database and does not need to be updated at this time.');
return Command::SUCCESS; return Command::SUCCESS;

View File

@ -54,7 +54,7 @@ class DomainRefreshController extends AbstractController
// If the domain name exists in the database, recently updated and not important, we return the stored Domain // If the domain name exists in the database, recently updated and not important, we return the stored Domain
if (null !== $domain if (null !== $domain
&& !$domain->getDeleted() && !$domain->getDeleted()
&& !$domain->isToBeUpdated() && !$domain->isToBeUpdated(true, true)
&& !$this->kernel->isDebug() && !$this->kernel->isDebug()
&& true !== filter_var($request->get('forced', false), FILTER_VALIDATE_BOOLEAN) && true !== filter_var($request->get('forced', false), FILTER_VALIDATE_BOOLEAN)
) { ) {

View File

@ -379,7 +379,7 @@ class Domain
* *
* @throws \Exception * @throws \Exception
*/ */
public function isToBeUpdated(bool $fromUser = true): bool public function isToBeUpdated(bool $fromUser = true, bool $intensifyLastDay = false): bool
{ {
$updatedAtDiff = $this->getUpdatedAt()->diff(new \DateTimeImmutable()); $updatedAtDiff = $this->getUpdatedAt()->diff(new \DateTimeImmutable());
@ -393,7 +393,7 @@ class Domain
$expiresIn = $this->getExpiresInDays(); $expiresIn = $this->getExpiresInDays();
if (0 === $expiresIn || 1 === $expiresIn) { if ($intensifyLastDay && (0 === $expiresIn || 1 === $expiresIn)) {
return true; return true;
} }

View File

@ -92,7 +92,7 @@ final readonly class UpdateDomainsFromWatchlistHandler
*/ */
/** @var Domain $domain */ /** @var Domain $domain */
foreach ($watchList->getDomains()->filter(fn ($domain) => $domain->isToBeUpdated(false)) as $domain foreach ($watchList->getDomains()->filter(fn ($domain) => $domain->isToBeUpdated(false, null !== $watchList->getConnector())) as $domain
) { ) {
$updatedAt = $domain->getUpdatedAt(); $updatedAt = $domain->getUpdatedAt();