mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
refactor: optimize getTrackedDomains
This commit is contained in:
@@ -4,6 +4,7 @@ namespace App\Repository;
|
||||
|
||||
use App\Entity\Domain;
|
||||
use App\Entity\Tld;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
@@ -51,6 +52,22 @@ class DomainRepository extends ServiceEntityRepository
|
||||
->getQuery()->execute();
|
||||
}
|
||||
|
||||
public function getMyTrackedDomains(User $user): array
|
||||
{
|
||||
return $this->createQueryBuilder('d')
|
||||
->select('d')
|
||||
->distinct()
|
||||
->join('d.watchLists', 'w')
|
||||
->join('d.events', 'de')
|
||||
->where('w.user = :user')
|
||||
->andWhere('d.deleted = false')
|
||||
->andWhere("de.action = 'expiration'")
|
||||
->andWhere('de.deleted = false')
|
||||
->getQuery()
|
||||
->setParameter('user', $user)
|
||||
->execute();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Domain[] Returns an array of Domain objects
|
||||
// */
|
||||
|
||||
Reference in New Issue
Block a user