Skip to content

Commit

Permalink
Introducing partial reindexes (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
Toflar authored Dec 18, 2024
1 parent 0d60bc0 commit 1939f67
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Console/ReindexCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace CmsIg\Seal\Integration\Spiral\Console;

use CmsIg\Seal\EngineRegistry;
use CmsIg\Seal\Reindex\ReindexConfig;
use CmsIg\Seal\Reindex\ReindexProviderInterface;
use Spiral\Console\Attribute\AsCommand;
use Spiral\Console\Attribute\Option;
Expand Down Expand Up @@ -53,6 +54,11 @@ public function __construct(
public function __invoke(
EngineRegistry $engineRegistry,
): int {
$reindexConfig = ReindexConfig::create()
->withIndex($this->indexName)
->withBulkSize($this->bulkSize)
->withDropIndex($this->drop);

foreach ($engineRegistry->getEngines() as $name => $engine) {
if ($this->engineName && $this->engineName !== $name) {
continue;
Expand All @@ -64,9 +70,7 @@ public function __invoke(

$engine->reindex(
$this->reindexProviders,
$this->indexName,
$this->drop,
$this->bulkSize,
$reindexConfig,
function (string $index, int $count, int|null $total) use ($progressBar) {
if (null !== $total) {
$progressBar->setMaxSteps($total);
Expand Down

0 comments on commit 1939f67

Please sign in to comment.