Add output to the import handler to help with debugging

This commit is contained in:
Leonard Smith 2021-05-01 16:42:58 -05:00
parent 6e4cb11206
commit ac6b2d5832
2 changed files with 15 additions and 3 deletions

View File

@ -39,6 +39,7 @@ class ImportUlbXmlData extends Command
*/
public function handle()
{
$this->info('Clearing out existing NT data...');
DB::statement("SET FOREIGN_KEY_CHECKS=0");
DB::table('verses')->truncate();
DB::table('chapters')->truncate();
@ -46,7 +47,8 @@ class ImportUlbXmlData extends Command
DB::table('words')->truncate();
DB::statement("SET FOREIGN_KEY_CHECKS=1");
$importHandler = new UlbXmlImportHandler();
$this->info('Importing fresh NT data...');
$importHandler = new UlbXmlImportHandler($this->output);
$importHandler->run();
}
}

View File

@ -7,6 +7,10 @@ use App\Word;
use App\Verse;
use DOMDocument;
use DOMElement;
use DOMNodeList;
use Illuminate\Console\OutputStyle;
use Symfony\Component\Console\Output\OutputInterface;
/**
* UlbXmlImportHandler.php
*
@ -45,6 +49,7 @@ class UlbXmlImportHandler
foreach ($this->availableFiles as $name => $filepath) {
$this->importBook($name, $filepath);
}
$this->output->writeln("<info>DONE.</info>", OutputInterface::VERBOSITY_NORMAL);
}
/**
@ -54,8 +59,11 @@ class UlbXmlImportHandler
*/
public function importBook(string $bookTitle, string $filepath) : Book
{
/** @var DOMDocument $document */
$document = $this->openBook($filepath);
$this->currentBookNumber = $this->parseBookNumberFromFilepath($filepath);
$this->output->write("<info>Importing $bookTitle from $filepath</info> Chapters: ", false, OutputInterface::VERBOSITY_NORMAL);
$this->document = $this->openBook($filepath);
$book = Book::create([
'id' => strtolower($bookTitle),
@ -69,6 +77,8 @@ class UlbXmlImportHandler
$book->chapters()->save($chapter);
}
$this->output->write("<info>Done.</info>", true, OutputInterface::VERBOSITY_NORMAL);
return $book;
}