mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
refactor: move DQL in repositories
This commit is contained in:
@@ -64,15 +64,7 @@ final readonly class SendDomainEventNotifHandler
|
||||
*/
|
||||
|
||||
/** @var DomainEvent[] $newEvents */
|
||||
$newEvents = $this->domainEventRepository->createQueryBuilder('de')
|
||||
->select()
|
||||
->where('de.domain = :domain')
|
||||
->andWhere('de.date > :updatedAt')
|
||||
->andWhere('de.date < :now')
|
||||
->setParameter('domain', $domain)
|
||||
->setParameter('updatedAt', $message->updatedAt)
|
||||
->setParameter('now', new \DateTimeImmutable())
|
||||
->getQuery()->getResult();
|
||||
$newEvents = $this->domainEventRepository->findNewDomainEvents($domain, $message->updatedAt);
|
||||
|
||||
foreach ($newEvents as $event) {
|
||||
if (!in_array($event->getAction(), $watchList->getTrackedEvents())) {
|
||||
@@ -111,15 +103,7 @@ final readonly class SendDomainEventNotifHandler
|
||||
}
|
||||
|
||||
/** @var DomainStatus $domainStatus */
|
||||
$domainStatus = $this->domainStatusRepository->createQueryBuilder('ds')
|
||||
->select()
|
||||
->where('ds.domain = :domain')
|
||||
->andWhere('ds.date = :date')
|
||||
->orderBy('ds.createdAt', 'DESC')
|
||||
->setParameter('domain', $domain)
|
||||
->setParameter('date', $message->updatedAt)
|
||||
->getQuery()
|
||||
->getOneOrNullResult();
|
||||
$domainStatus = $this->domainStatusRepository->findNewDomainStatus($domain, $message->updatedAt);
|
||||
|
||||
if (null !== $domainStatus && count(array_intersect(
|
||||
$watchList->getTrackedEppStatus(),
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\MessageHandler;
|
||||
|
||||
use App\Message\UpdateRdapServers;
|
||||
use App\Repository\DomainRepository;
|
||||
use App\Service\OfficialDataService;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Messenger\Attribute\AsMessageHandler;
|
||||
@@ -17,7 +18,7 @@ final readonly class UpdateRdapServersHandler
|
||||
{
|
||||
public function __construct(
|
||||
private OfficialDataService $officialDataService,
|
||||
private ParameterBagInterface $bag,
|
||||
private ParameterBagInterface $bag, private DomainRepository $domainRepository,
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -41,7 +42,7 @@ final readonly class UpdateRdapServersHandler
|
||||
try {
|
||||
$this->officialDataService->updateTldListIANA();
|
||||
$this->officialDataService->updateGTldListICANN();
|
||||
$this->officialDataService->updateDomainsWhenTldIsDeleted();
|
||||
$this->domainRepository->setDomainDeletedIfTldIsDeleted();
|
||||
} catch (\Throwable $throwable) {
|
||||
$throws[] = $throwable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user