From f92a720d63b5e8aa7a425bd60d3a0747244d2879 Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 3 Apr 2024 09:06:43 +0200 Subject: [PATCH] Use short_url_visits_counts table when excluding short URLs which reached max visits --- .../Core/src/ShortUrl/Repository/ShortUrlListRepository.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/Core/src/ShortUrl/Repository/ShortUrlListRepository.php b/module/Core/src/ShortUrl/Repository/ShortUrlListRepository.php index e66bbdc2..b639ace4 100644 --- a/module/Core/src/ShortUrl/Repository/ShortUrlListRepository.php +++ b/module/Core/src/ShortUrl/Repository/ShortUrlListRepository.php @@ -147,7 +147,10 @@ class ShortUrlListRepository extends EntitySpecificationRepository implements Sh $qb->expr()->isNull('s.maxVisits'), $qb->expr()->gt( 's.maxVisits', - sprintf('(SELECT COUNT(innerV.id) FROM %s as innerV WHERE innerV.shortUrl=s)', Visit::class), + sprintf( + '(SELECT COALESCE(SUM(vc.count), 0) FROM %s as vc WHERE vc.shortUrl=s)', + ShortUrlVisitsCount::class, + ), ), )); }