66use Doctrine \DBAL \Exception as ExceptionDbal ;
77use In2code \Lux \Domain \Model \Visitor ;
88use In2code \Lux \Domain \Repository \VisitorRepository ;
9+ use In2code \Lux \Exception \DateTimeException ;
910use Symfony \Component \Console \Command \Command ;
1011use Symfony \Component \Console \Input \InputArgument ;
1112use Symfony \Component \Console \Input \InputInterface ;
@@ -30,19 +31,27 @@ public function configure()
3031 * Remove all unknown visitors where the last update (tstamp) is older than a given timestamp
3132 * !!! Really removes visitors and all rows from related tables from the database
3233 *
33- * Example command: /vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge 1583410470
34+ * Example commands:
35+ * - absolute date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge 1583410470
36+ * - absolute date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge '2010-01-01'
37+ * - relative date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge 'First day of this month'
38+ * - relative date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge 'First day of last month'
39+ * - relative date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge 'First day of this year'
40+ * - relative date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge -- '-30 days'
41+ * - relative date: ./vendor/bin/typo3 lux:cleanupUnknownVisitorsByAge -- '-2678400 seconds'
3442 *
3543 * @param InputInterface $input
3644 * @param OutputInterface $output
3745 * @return int
3846 * @throws InvalidQueryException
3947 * @throws ExceptionDbal
48+ * @throws DateTimeException
4049 */
4150 public function execute (InputInterface $ input , OutputInterface $ output ): int
4251 {
4352 $ this ->initializeExtbase ();
4453 $ visitorRepository = GeneralUtility::makeInstance (VisitorRepository::class);
45- $ visitors = $ visitorRepository ->findByLastChangeUnknown (( int ) $ input ->getArgument ('timestamp ' ));
54+ $ visitors = $ visitorRepository ->findByLastChangeUnknown ($ this -> parseTime ( $ input ->getArgument ('timestamp ' ) ));
4655 /** @var Visitor $visitor */
4756 foreach ($ visitors as $ visitor ) {
4857 $ visitorRepository ->removeVisitor ($ visitor );
0 commit comments