Extend and normalize output from visits console commands

This commit is contained in:
Alejandro Celaya
2026-01-03 11:45:29 +01:00
parent 0d964f0fde
commit 900de9e800
16 changed files with 105 additions and 200 deletions

View File

@@ -6,8 +6,6 @@ namespace Shlinkio\Shlink\CLI\Command\Visit;
use Shlinkio\Shlink\CLI\Input\VisitsListInput;
use Shlinkio\Shlink\Core\Domain\Entity\Domain;
use Shlinkio\Shlink\Core\ShortUrl\Helper\ShortUrlStringifierInterface;
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
use Shlinkio\Shlink\Core\Visit\Model\WithDomainVisitsParams;
use Shlinkio\Shlink\Core\Visit\VisitsStatsHelperInterface;
use Symfony\Component\Console\Attribute\AsCommand;
@@ -21,10 +19,8 @@ class GetNonOrphanVisitsCommand extends Command
{
public const string NAME = 'visit:non-orphan';
public function __construct(
private readonly VisitsStatsHelperInterface $visitsHelper,
private readonly ShortUrlStringifierInterface $shortUrlStringifier,
) {
public function __construct(private readonly VisitsStatsHelperInterface $visitsHelper)
{
parent::__construct();
}
@@ -42,17 +38,8 @@ class GetNonOrphanVisitsCommand extends Command
dateRange: $input->dateRange(),
domain: $domain,
));
VisitsCommandUtils::renderOutput($io, $input, $paginator, $this->mapExtraFields(...));
VisitsCommandUtils::renderOutput($io, $input, $paginator);
return self::SUCCESS;
}
/**
* @return array<string, string>
*/
private function mapExtraFields(Visit $visit): array
{
$shortUrl = $visit->shortUrl;
return $shortUrl === null ? [] : ['shortUrl' => $this->shortUrlStringifier->stringify($shortUrl)];
}
}