diff --git a/composer.json b/composer.json index 9782b137..0c088a77 100644 --- a/composer.json +++ b/composer.json @@ -49,7 +49,7 @@ "shlinkio/shlink-common": "dev-main#554e370 as 3.7", "shlinkio/shlink-config": "^1.0", "shlinkio/shlink-event-dispatcher": "^2.1", - "shlinkio/shlink-importer": "dev-main#174e352 as 2.3", + "shlinkio/shlink-importer": "dev-main#39928b6 as 2.3", "shlinkio/shlink-installer": "dev-develop#aa50ea9 as 5.5", "shlinkio/shlink-ip-geolocation": "^1.5", "symfony/console": "^5.1", diff --git a/module/Core/src/Importer/ImportedLinksProcessor.php b/module/Core/src/Importer/ImportedLinksProcessor.php index 4a5562bc..7cecd5fe 100644 --- a/module/Core/src/Importer/ImportedLinksProcessor.php +++ b/module/Core/src/Importer/ImportedLinksProcessor.php @@ -64,14 +64,7 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface } $this->em->persist($shortUrl); - - // TODO Process only missing visits when possible: $importedUrl->visitsCount(); - // TODO Make importing visits optional based on params - $importedVisits = 0; - foreach ($importedUrl->visits() as $importedVisit) { - $this->em->persist(Visit::fromImport($importedVisit, $shortUrl)); - $importedVisits++; - } + $importedVisits = $this->importVisits($importedUrl, $shortUrl); $io->text( $importedVisits === 0 @@ -105,4 +98,16 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface return $this->shortCodeHelper->ensureShortCodeUniqueness($shortUrl, false); } + + private function importVisits(ImportedShlinkUrl $importedUrl, ShortUrl $shortUrl): int + { + // TODO Process only missing visits when possible: $importedUrl->visitsCount(); + $importedVisits = 0; + foreach ($importedUrl->visits() as $importedVisit) { + $this->em->persist(Visit::fromImport($importedVisit, $shortUrl)); + $importedVisits++; + } + + return $importedVisits; + } }