Added a console command to check for mismatched strongs entries
This commit is contained in:
parent
df937b5795
commit
b8e68aec47
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\LexicalEntry;
|
||||
use App\Word;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
/**
|
||||
* CheckForMissingStrongsNumbers.php
|
||||
*
|
||||
* @author: Leonard Smith <leonard@acornwebconsultants.com>
|
||||
* Date: 5/6/21
|
||||
* Time: 10:06 AM
|
||||
*/
|
||||
class CheckForMissingStrongsNumbers extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'gwt:check-strongs-numbers';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Check the words table for unmatched strongs numbers';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$words = Word::all();
|
||||
$total = count($words);
|
||||
$this->info("Checking $total words for mismatched strong's numbers");
|
||||
|
||||
$mismatches = 0;
|
||||
foreach ($words as $word) {
|
||||
if (!empty($word->strongs_number) && $word->strongs_number !== '-1') {
|
||||
$lexicalEntry = LexicalEntry::find($word->strongs_number);
|
||||
|
||||
if (empty($lexicalEntry)) {
|
||||
$this->info("No Lexical Entry found for $word->id | $word->strongs_number");
|
||||
$mismatches++;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->info("Found $mismatches mismatches out of $total entries");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue