Added exclusion flags to ListShortUrlsCommand

This commit is contained in:
Alejandro Celaya 2022-12-11 18:33:40 +01:00
parent c4f28b3a32
commit 0952c488be
2 changed files with 14 additions and 2 deletions

View File

@ -79,13 +79,13 @@ class ListShortUrlsCommand extends Command
) )
->addOption( ->addOption(
'exclude-max-visits-reached', 'exclude-max-visits-reached',
null, // TODO null,
InputOption::VALUE_NONE, InputOption::VALUE_NONE,
'Excludes short URLs which reached their max amount of visits.', 'Excludes short URLs which reached their max amount of visits.',
) )
->addOption( ->addOption(
'exclude-past-valid-until', 'exclude-past-valid-until',
null, // TODO null,
InputOption::VALUE_NONE, InputOption::VALUE_NONE,
'Excludes short URLs which have a "validUntil" date in the past.', 'Excludes short URLs which have a "validUntil" date in the past.',
) )
@ -145,6 +145,8 @@ class ListShortUrlsCommand extends Command
ShortUrlsParamsInputFilter::ORDER_BY => $orderBy, ShortUrlsParamsInputFilter::ORDER_BY => $orderBy,
ShortUrlsParamsInputFilter::START_DATE => $startDate?->toAtomString(), ShortUrlsParamsInputFilter::START_DATE => $startDate?->toAtomString(),
ShortUrlsParamsInputFilter::END_DATE => $endDate?->toAtomString(), ShortUrlsParamsInputFilter::END_DATE => $endDate?->toAtomString(),
ShortUrlsParamsInputFilter::EXCLUDE_MAX_VISITS_REACHED => $input->getOption('exclude-max-visits-reached'),
ShortUrlsParamsInputFilter::EXCLUDE_PAST_VALID_UNTIL => $input->getOption('exclude-past-valid-until'),
]; ];
if ($all) { if ($all) {

View File

@ -61,6 +61,16 @@ class ListShortUrlsTest extends CliTestCase
| custom-with-domain | | http://some-domain.com/custom-with-domain | https://google.com | 2018-10-20T00:00:00+00:00 | 0 | | custom-with-domain | | http://some-domain.com/custom-with-domain | https://google.com | 2018-10-20T00:00:00+00:00 | 0 |
+--------------------+-------+-------------------------------------------+----------------------------- Page 1 of 1 -----------------------------------------------------------+---------------------------+--------------+ +--------------------+-------+-------------------------------------------+----------------------------- Page 1 of 1 -----------------------------------------------------------+---------------------------+--------------+
OUTPUT]; OUTPUT];
yield 'expired excluded' => [['--exclude-max-visits-reached', '--exclude-past-valid-until'], <<<OUTPUT
+--------------------+-------+-------------------------------------------+-----------------------------------------------------------------------------------------------------------+---------------------------+--------------+
| Short Code | Title | Short URL | Long URL | Date created | Visits count |
+--------------------+-------+-------------------------------------------+-----------------------------------------------------------------------------------------------------------+---------------------------+--------------+
| ghi789 | | http://example.com/ghi789 | https://blog.alejandrocelaya.com/2019/04/27/considerations-to-properly-use-open-source-software-projects/ | 2019-01-01T00:00:30+00:00 | 0 |
| custom | | http://doma.in/custom | https://shlink.io | 2019-01-01T00:00:20+00:00 | 0 |
| def456 | | http://doma.in/def456 | https://blog.alejandrocelaya.com/2017/12/09/acmailer-7-0-the-most-important-release-in-a-long-time/ | 2019-01-01T00:00:10+00:00 | 2 |
| custom-with-domain | | http://some-domain.com/custom-with-domain | https://google.com | 2018-10-20T00:00:00+00:00 | 0 |
+--------------------+-------+-------------------------------------------+-------------------------------- Page 1 of 1 --------------------------------------------------------------+---------------------------+--------------+
OUTPUT];
// phpcs:enable // phpcs:enable
} }
} }