Skip to content

Commit

Permalink
Improve seeder validation output
Browse files Browse the repository at this point in the history
  • Loading branch information
driftingly committed May 7, 2024
1 parent 9c4e232 commit 4fb78b4
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions app/Console/Commands/ValidateSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public function handle()
'Artwork',
$artwork,
$translation,
$locale
$locale,
['theme' => $theme, 'prompt' => $prompt, 'artwork' => $artwork]
))
)
);
Expand All @@ -58,21 +59,32 @@ private function checkImg(
string $type,
array $object,
array $translation,
string $locale
string $locale,
array $meta = []
): void {
$url1 = Arr::get($object, $field);
$url2 = Arr::get($translation, $field);

if ($url1 !== $url2) {
$similarity = $this->getSimilarity($url1, $url2);

if ($similarity > 70) {
if ($similarity > 50) {
return;
}

$this->error($type.' '.$object['id'].' Img:'.$url1);
$this->error(Str::upper($locale).' '.$type.' '.$translation['id'].' Img:'.$url2);
$this->error('Similarity: '.$similarity);
if ($type === 'Theme') {
$this->comment('Theme: '.$object['title']);
}

if ($type === 'Artwork') {
$this->comment('Theme: '.$meta['theme']['title']);
$this->comment('Prompt: '.$meta['prompt']['title']);
$this->comment('Artwork: '.$meta['artwork']['title']);
}

$this->comment('EN ID: '.$object['id'].' Img: '.$url1);
$this->comment(Str::upper($locale).' ID: '.$translation['id'].' Img: '.$url2);
$this->comment('Image Similarity: '.$similarity);
$this->newLine(2);
}
}
Expand Down

0 comments on commit 4fb78b4

Please sign in to comment.