mirror of
https://github.com/shlinkio/shlink.git
synced 2026-02-28 12:13:13 +08:00
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Shlinkio\Shlink\CLI\Command\Visit;
|
|
|
|
use Shlinkio\Shlink\Common\Paginator\Paginator;
|
|
use Shlinkio\Shlink\Common\Util\DateRange;
|
|
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface;
|
|
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
|
|
use Shlinkio\Shlink\Core\Visit\Model\VisitsParams;
|
|
use Shlinkio\Shlink\Core\Visit\VisitsStatsHelperInterface;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
class GetNonOrphanVisitsCommand extends AbstractVisitsListCommand
|
|
{
|
|
public const NAME = 'visit:non-orphan';
|
|
|
|
public function __construct(
|
|
VisitsStatsHelperInterface $visitsHelper,
|
|
private readonly ShortUrlStringifierInterface $shortUrlStringifier,
|
|
) {
|
|
parent::__construct($visitsHelper);
|
|
}
|
|
|
|
protected function configure(): void
|
|
{
|
|
$this
|
|
->setName(self::NAME)
|
|
->setDescription('Returns the list of non-orphan visits.');
|
|
}
|
|
|
|
protected function getVisitsPaginator(InputInterface $input, DateRange $dateRange): Paginator
|
|
{
|
|
return $this->visitsHelper->nonOrphanVisits(new VisitsParams($dateRange));
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function mapExtraFields(Visit $visit): array
|
|
{
|
|
$shortUrl = $visit->shortUrl;
|
|
return $shortUrl === null ? [] : ['shortUrl' => $this->shortUrlStringifier->stringify($shortUrl)];
|
|
}
|
|
}
|