Use short_url_visits_counts table when excluding short URLs which reached max visits

This commit is contained in:
Alejandro Celaya 2024-04-03 09:06:43 +02:00
parent d6f58698b7
commit f92a720d63

View file

@ -147,7 +147,10 @@ class ShortUrlListRepository extends EntitySpecificationRepository implements Sh
$qb->expr()->isNull('s.maxVisits'), $qb->expr()->isNull('s.maxVisits'),
$qb->expr()->gt( $qb->expr()->gt(
's.maxVisits', '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,
),
), ),
)); ));
} }