From f8682dc8688e8c66f919439038962062a4cfd0d9 Mon Sep 17 00:00:00 2001 From: Daniel Lienert Date: Mon, 2 Aug 2021 06:47:03 +0200 Subject: [PATCH] WIP: Replace group by with join --- .../Domain/Repository/FormDataRepository.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/Classes/Domain/Repository/FormDataRepository.php b/Classes/Domain/Repository/FormDataRepository.php index 79ff67f..e73458f 100644 --- a/Classes/Domain/Repository/FormDataRepository.php +++ b/Classes/Domain/Repository/FormDataRepository.php @@ -47,14 +47,26 @@ public function initializeObject(): void */ public function findAllUniqueForms(): iterable { - $queryBuilder = $this->createQueryBuilder('form'); - return $queryBuilder + + $subSelectQb = $this->createQueryBuilder('form') + ->select('form.Persistence_Object_Identifier') ->groupBy('form.formIdentifier') - ->addGroupBy('form.hash') + ->addGroupBy('form.hash'); + + $queryBuilder = $this->createQueryBuilder('form'); + + + $query = $queryBuilder ->addSelect('count(form) AS entryCount') ->addSelect('MAX(form.date) as latestDate') + ->andWhere( + $queryBuilder->expr()->in('form.Persistence_Object_Identifier', $subSelectQb->getQuery()->getSQL()) + ) ->orderBy('latestDate', 'DESC') - ->getQuery()->execute(); + ->getQuery(); + + \Neos\Flow\var_dump($query->getSQL(), __METHOD__ . ':' . __LINE__); + die(); } /**