From 0af5f111bedc5f10e8b4f63ca56e7c8739e2d36e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lys=C3=BD?= Date: Tue, 19 Oct 2021 11:15:53 +0200 Subject: [PATCH] Add new function for getting count of segments with more filters [MAILPOET-3427] --- lib/Segments/SegmentsRepository.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/Segments/SegmentsRepository.php b/lib/Segments/SegmentsRepository.php index cce79c6888..a68646ce46 100644 --- a/lib/Segments/SegmentsRepository.php +++ b/lib/Segments/SegmentsRepository.php @@ -221,4 +221,14 @@ class SegmentsRepository extends Repository { ->setMaxResults($limit) ->getResult(); } + + public function getCountWithMultipleConditions(): int { + $qb = $this->entityManager->createQueryBuilder() + ->select('COUNT(DISTINCT s.id)') + ->from(SegmentEntity::class, 's') + ->join('s.dynamicFilters', 'ds') + ->groupBy('ds.segment') + ->having('COUNT(ds.id) > 1'); + return (int)$qb->getQuery()->getSingleScalarResult(); + } }