Moved visits iteration logic from command to service to allow lazy loading of entries in resultset

This commit is contained in:
Alejandro Celaya
2018-11-17 09:42:15 +01:00
parent 1bc01057f3
commit 0aae0d888c
9 changed files with 229 additions and 124 deletions

View File

@@ -10,15 +10,12 @@ use Shlinkio\Shlink\Core\Entity\Visit;
class VisitRepository extends EntityRepository implements VisitRepositoryInterface
{
/**
* @return Visit[]
*/
public function findUnlocatedVisits(): array
public function findUnlocatedVisits(): iterable
{
$qb = $this->createQueryBuilder('v');
$qb->where($qb->expr()->isNull('v.visitLocation'));
return $qb->getQuery()->getResult();
return $qb->getQuery()->iterate();
}
/**

View File

@@ -10,10 +10,7 @@ use Shlinkio\Shlink\Core\Entity\Visit;
interface VisitRepositoryInterface extends ObjectRepository
{
/**
* @return Visit[]
*/
public function findUnlocatedVisits(): array;
public function findUnlocatedVisits(): iterable;
/**
* @param ShortUrl|int $shortUrl