Added split info about bots, non-bots and total visits to the visits stats

This commit is contained in:
Alejandro Celaya
2023-01-02 12:28:34 +01:00
parent e71f6bb528
commit 37c8328eed
8 changed files with 82 additions and 45 deletions

View File

@@ -32,7 +32,7 @@ use Shlinkio\Shlink\Rest\Entity\ApiKey;
class VisitsStatsHelper implements VisitsStatsHelperInterface
{
public function __construct(private EntityManagerInterface $em)
public function __construct(private readonly EntityManagerInterface $em)
{
}
@@ -42,13 +42,17 @@ class VisitsStatsHelper implements VisitsStatsHelperInterface
$visitsRepo = $this->em->getRepository(Visit::class);
return new VisitsStats(
$visitsRepo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey)),
$visitsRepo->countOrphanVisits(new VisitsCountFiltering()),
nonOrphanVisitsTotal: $visitsRepo->countNonOrphanVisits(VisitsCountFiltering::withApiKey($apiKey)),
orphanVisitsTotal: $visitsRepo->countOrphanVisits(new VisitsCountFiltering()),
nonOrphanVisitsNonBots: $visitsRepo->countNonOrphanVisits(
new VisitsCountFiltering(excludeBots: true, apiKey: $apiKey),
),
orphanVisitsNonBots: $visitsRepo->countOrphanVisits(new VisitsCountFiltering(excludeBots: true)),
);
}
/**
* @return Visit[]|Paginator
* @return Paginator<Visit>
* @throws ShortUrlNotFoundException
*/
public function visitsForShortUrl(