mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 09:43:13 +08:00
Renamed countVisits to countNonOrphanVisits, and updated its signature to expect a VisitsCountFiltering DTO
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -16,6 +16,11 @@ class VisitsCountFiltering
|
||||
) {
|
||||
}
|
||||
|
||||
public static function withApiKey(?ApiKey $apiKey): self
|
||||
{
|
||||
return new self(null, false, $apiKey);
|
||||
}
|
||||
|
||||
public function dateRange(): ?DateRange
|
||||
{
|
||||
return $this->dateRange;
|
||||
|
||||
@@ -37,7 +37,7 @@ class VisitsStatsHelper implements VisitsStatsHelperInterface
|
||||
$visitsRepo = $this->em->getRepository(Visit::class);
|
||||
|
||||
return new VisitsStats(
|
||||
$visitsRepo->countVisits($apiKey),
|
||||
$visitsRepo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey)),
|
||||
$visitsRepo->countOrphanVisits(new VisitsCountFiltering()),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user