Renamed countVisits to countNonOrphanVisits, and updated its signature to expect a VisitsCountFiltering DTO

This commit is contained in:
Alejandro Celaya
2022-01-16 11:15:39 +01:00
parent 60c0ca3ae5
commit 61618250ec
6 changed files with 14 additions and 12 deletions

View File

@@ -16,7 +16,6 @@ use Shlinkio\Shlink\Core\Visit\Persistence\VisitsCountFiltering;
use Shlinkio\Shlink\Core\Visit\Persistence\VisitsListFiltering;
use Shlinkio\Shlink\Core\Visit\Spec\CountOfOrphanVisits;
use Shlinkio\Shlink\Core\Visit\Spec\CountOfShortUrlVisits;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
use const PHP_INT_MAX;
@@ -181,10 +180,9 @@ class VisitRepository extends EntitySpecificationRepository implements VisitRepo
}
// TODO This should support counting in a date range or excluding bots
// TODO Rename to countNonOrphanVisits
public function countVisits(?ApiKey $apiKey = null): int
public function countNonOrphanVisits(VisitsCountFiltering $filtering): int
{
return (int) $this->matchSingleScalarResult(new CountOfShortUrlVisits($apiKey));
return (int) $this->matchSingleScalarResult(new CountOfShortUrlVisits($filtering->apiKey()));
}
private function createAllVisitsQueryBuilder(VisitsListFiltering $filtering): QueryBuilder

View File

@@ -10,7 +10,6 @@ use Shlinkio\Shlink\Core\Entity\Visit;
use Shlinkio\Shlink\Core\Model\ShortUrlIdentifier;
use Shlinkio\Shlink\Core\Visit\Persistence\VisitsCountFiltering;
use Shlinkio\Shlink\Core\Visit\Persistence\VisitsListFiltering;
use Shlinkio\Shlink\Rest\Entity\ApiKey;
// TODO Split into VisitsListsRepository and VisitsLocationRepository
interface VisitRepositoryInterface extends ObjectRepository, EntitySpecificationRepositoryInterface
@@ -58,5 +57,5 @@ interface VisitRepositoryInterface extends ObjectRepository, EntitySpecification
*/
public function findNonOrphanVisits(VisitsListFiltering $filtering): array;
public function countVisits(?ApiKey $apiKey = null): int;
public function countNonOrphanVisits(VisitsCountFiltering $filtering): int;
}