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:
@@ -34,22 +34,10 @@ class StatisticsController extends AbstractController
|
||||
->setAlertSent($this->pool->getItem('stats.alert.sent')->get() ?? 0)
|
||||
|
||||
->setDomainTracked(
|
||||
$this->getCachedItem('stats.domain.tracked', fn () => $this->watchListRepository->createQueryBuilder('w')
|
||||
->join('w.domains', 'd')
|
||||
->select('COUNT(DISTINCT d.ldhName)')
|
||||
->where('d.deleted = FALSE')
|
||||
->getQuery()->getSingleColumnResult()[0])
|
||||
$this->getCachedItem('stats.domain.tracked', fn () => $this->watchListRepository->getTrackedDomainCount())
|
||||
)
|
||||
->setDomainCount(
|
||||
$this->getCachedItem('stats.domain.count', fn () => $this->domainRepository->createQueryBuilder('d')
|
||||
->join('d.tld', 't')
|
||||
->select('t.tld tld')
|
||||
->addSelect('COUNT(d.ldhName) AS domain')
|
||||
->addGroupBy('t.tld')
|
||||
->where('d.deleted = FALSE')
|
||||
->orderBy('domain', 'DESC')
|
||||
->setMaxResults(5)
|
||||
->getQuery()->getArrayResult())
|
||||
$this->getCachedItem('stats.domain.count', fn () => $this->domainRepository->getActiveDomainCountByTld())
|
||||
)
|
||||
->setDomainCountTotal(
|
||||
$this->getCachedItem('stats.domain.total', fn () => $this->domainRepository->count(['deleted' => false])
|
||||
|
||||
@@ -110,16 +110,7 @@ class WatchListController extends AbstractController
|
||||
/** @var Domain $domain */
|
||||
foreach ($watchList->getDomains()->getIterator() as $domain) {
|
||||
/** @var DomainEvent|null $exp */
|
||||
$exp = $this->domainEventRepository->createQueryBuilder('de')
|
||||
->select()
|
||||
->where('de.domain = :domain')
|
||||
->andWhere('de.action = \'expiration\'')
|
||||
->andWhere('de.deleted = FALSE')
|
||||
->orderBy('de.date', 'DESC')
|
||||
->setMaxResults(1)
|
||||
->getQuery()
|
||||
->setParameter('domain', $domain)
|
||||
->getOneOrNullResult();
|
||||
$exp = $this->domainEventRepository->findLastExpirationDomainEvent($domain);
|
||||
|
||||
if (!$domain->getDeleted() && null !== $exp && !in_array($domain, $domains)) {
|
||||
$domains[] = $domain;
|
||||
|
||||
Reference in New Issue
Block a user