Changed point in which specs are applied for tags list

This commit is contained in:
Alejandro Celaya 2021-01-03 12:00:25 +01:00
parent df53e6c6f2
commit 6e1d6ab795

View file

@ -31,13 +31,17 @@ class TagRepository extends EntitySpecificationRepository implements TagReposito
*/
public function findTagsWithInfo(?Specification $spec = null): array
{
$qb = $this->getQueryBuilder($spec, 't');
$qb = $this->createQueryBuilder('t');
$qb->select('t AS tag', 'COUNT(DISTINCT s.id) AS shortUrlsCount', 'COUNT(DISTINCT v.id) AS visitsCount')
->leftJoin('t.shortUrls', 's')
->leftJoin('s.visits', 'v')
->groupBy('t')
->orderBy('t.name', 'ASC');
if ($spec !== null) {
$this->applySpecification($qb, $spec, 't');
}
$query = $qb->getQuery();
return map(