From 02032ed7239aa935c2e09377e9312adf72f6a1fa Mon Sep 17 00:00:00 2001 From: asajedi Date: Tue, 7 Dec 2021 03:16:50 +0100 Subject: [PATCH] Exclude sample TEI document from indexing --- src/Command/SolrIndexing.php | 11 +++++++---- src/Import/Importer.php | 7 +++++-- src/Import/ImporterInterface.php | 2 +- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Command/SolrIndexing.php b/src/Command/SolrIndexing.php index 6a0837a..74b7dbb 100644 --- a/src/Command/SolrIndexing.php +++ b/src/Command/SolrIndexing.php @@ -7,11 +7,13 @@ namespace App\Command; use App\Import\ImporterInterface; use App\Index\IndexerInterface; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class SolrIndexing extends Command { + protected static string $description = 'Process TEI data to solr data for importing into solr.'; protected static $defaultName = 'app:start_indexing'; private ImporterInterface $importer; private IndexerInterface $indexer; @@ -28,7 +30,9 @@ class SolrIndexing extends Command */ protected function configure() { - $this->setDescription('Process TEI data to solr data for importing into solr.'); + $this + ->setDescription(self::$description) + ->addArgument('server', InputArgument::REQUIRED, 'Server Type');; } /** @@ -36,12 +40,11 @@ class SolrIndexing extends Command */ protected function execute(InputInterface $input, OutputInterface $output): int { + $server = $input->getArgument('server'); $output->writeln('Start solr indexing.'); - - $this->importer->import(); + $this->importer->import($server); $this->indexer->deleteSolrIndex(); $this->indexer->tei2solr(); - $time = microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']; $time /= 60; $output->writeln('Indexing process completed in '.$time.' minutes.'); diff --git a/src/Import/Importer.php b/src/Import/Importer.php index 15740b3..cffd9d9 100644 --- a/src/Import/Importer.php +++ b/src/Import/Importer.php @@ -85,9 +85,12 @@ class Importer implements ImporterInterface } } - public function import(): void + public function import(string $server): void { - $this->importSampleTeiDocument(); + if ('dev' === $server) { + $this->importSampleTeiDocument(); + } + $filesystem = new Filesystem(); if (!$filesystem->exists($this->teiDir)) { $filesystem->mkdir($this->teiDir); diff --git a/src/Import/ImporterInterface.php b/src/Import/ImporterInterface.php index 966fee6..26bcffa 100644 --- a/src/Import/ImporterInterface.php +++ b/src/Import/ImporterInterface.php @@ -4,5 +4,5 @@ namespace App\Import; interface ImporterInterface { - public function import(): void; + public function import(string $server): void; } -- GitLab