mirror of
https://github.com/shlinkio/shlink.git
synced 2024-12-22 15:13:59 -06:00
Updated to latest shlink-importer
This commit is contained in:
parent
4223408090
commit
4b66aaba5c
@ -48,7 +48,7 @@
|
||||
"shlinkio/shlink-common": "dev-main#7515008 as 5.2",
|
||||
"shlinkio/shlink-config": "dev-main#96c81fb as 2.3",
|
||||
"shlinkio/shlink-event-dispatcher": "^2.6",
|
||||
"shlinkio/shlink-importer": "^4.0",
|
||||
"shlinkio/shlink-importer": "dev-main#c97662b as 5.0",
|
||||
"shlinkio/shlink-installer": "^8.2",
|
||||
"shlinkio/shlink-ip-geolocation": "dev-main#e208963 as 3.2",
|
||||
"spiral/roadrunner": "^2.11",
|
||||
|
@ -13,6 +13,7 @@ use Shlinkio\Shlink\Core\ShortUrl\Resolver\ShortUrlRelationResolverInterface;
|
||||
use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||
use Shlinkio\Shlink\Importer\ImportedLinksProcessorInterface;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportResult;
|
||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
@ -34,14 +35,11 @@ class ImportedLinksProcessor implements ImportedLinksProcessorInterface
|
||||
$this->shortUrlRepo = $this->em->getRepository(ShortUrl::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iterable<ImportedShlinkUrl> $shlinkUrls
|
||||
*/
|
||||
public function process(StyleInterface $io, iterable $shlinkUrls, ImportParams $params): void
|
||||
public function process(StyleInterface $io, ImportResult $result, ImportParams $params): void
|
||||
{
|
||||
$importShortCodes = $params->importShortCodes;
|
||||
$source = $params->source;
|
||||
$iterable = $this->batchHelper->wrapIterable($shlinkUrls, $source === ImportSource::SHLINK ? 10 : 100);
|
||||
$iterable = $this->batchHelper->wrapIterable($result->shlinkUrls, $source === ImportSource::SHLINK ? 10 : 100);
|
||||
|
||||
/** @var ImportedShlinkUrl $importedUrl */
|
||||
foreach ($iterable as $importedUrl) {
|
||||
|
@ -19,6 +19,7 @@ use Shlinkio\Shlink\Core\Util\DoctrineBatchHelperInterface;
|
||||
use Shlinkio\Shlink\Core\Visit\Entity\Visit;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportedShlinkVisit;
|
||||
use Shlinkio\Shlink\Importer\Model\ImportResult;
|
||||
use Shlinkio\Shlink\Importer\Params\ImportParams;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||
use stdClass;
|
||||
@ -76,7 +77,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
);
|
||||
$this->io->expects($this->exactly($expectedCalls))->method('text')->with($this->isType('string'));
|
||||
|
||||
$this->processor->process($this->io, $urls, $this->buildParams());
|
||||
$this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams());
|
||||
}
|
||||
|
||||
/** @test */
|
||||
@ -99,7 +100,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
});
|
||||
$textCalls = $this->setUpIoText('<comment>Skipped</comment>. Reason: Whatever error', '<info>Imported</info>');
|
||||
|
||||
$this->processor->process($this->io, $urls, $this->buildParams());
|
||||
$this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams());
|
||||
|
||||
self::assertEquals(2, $textCalls->importedCount);
|
||||
self::assertEquals(1, $textCalls->skippedCount);
|
||||
@ -124,7 +125,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
$this->em->expects($this->exactly(2))->method('persist')->with($this->isInstanceOf(ShortUrl::class));
|
||||
$textCalls = $this->setUpIoText();
|
||||
|
||||
$this->processor->process($this->io, $urls, $this->buildParams());
|
||||
$this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams());
|
||||
|
||||
self::assertEquals(2, $textCalls->importedCount);
|
||||
self::assertEquals(3, $textCalls->skippedCount);
|
||||
@ -151,7 +152,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
});
|
||||
$textCalls = $this->setUpIoText('Error');
|
||||
|
||||
$this->processor->process($this->io, $urls, $this->buildParams());
|
||||
$this->processor->process($this->io, ImportResult::withShortUrls($urls), $this->buildParams());
|
||||
|
||||
self::assertEquals(2, $textCalls->importedCount);
|
||||
self::assertEquals(3, $textCalls->skippedCount);
|
||||
@ -176,7 +177,7 @@ class ImportedLinksProcessorTest extends TestCase
|
||||
)->with($this->callback(fn (object $arg) => $arg instanceof ShortUrl || $arg instanceof Visit));
|
||||
$this->io->expects($this->once())->method('text')->with($this->stringContains($expectedOutput));
|
||||
|
||||
$this->processor->process($this->io, [$importedUrl], $this->buildParams());
|
||||
$this->processor->process($this->io, ImportResult::withShortUrls([$importedUrl]), $this->buildParams());
|
||||
}
|
||||
|
||||
public function provideUrlsWithVisits(): iterable
|
||||
|
Loading…
Reference in New Issue
Block a user