Skip to content

Commit

Permalink
Lint code [WEB-2995]
Browse files Browse the repository at this point in the history
  • Loading branch information
web-dev-trev committed Jan 15, 2025
1 parent e01fcd1 commit bbf65af
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/Console/Commands/AI/AnalyzeAllArtworks.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function handle(): int
"Re-analyzing artworks last processed before: " . $cutoffDate->toDateTimeString(),
OutputInterface::VERBOSITY_VERBOSE
);

if ($startId) {
$this->info("Starting from artwork ID: " . $startId, OutputInterface::VERBOSITY_VERBOSE);
}
Expand All @@ -62,7 +62,7 @@ public function handle(): int
// Define custom placeholder names
$bar->setMessage('Processing artworks...');
$bar->setMessage('Starting...', 'title');

$bar->setFormat(
" %message%\n" .
" %current%/%max% [%bar%] %percent:3s%%\n" .
Expand All @@ -78,50 +78,50 @@ public function handle(): int

$query = $this->getArtworksToProcess($startId);
$query->chunk($chunkSize, function ($artworks) use (
&$processed,
&$skipped,
&$errors,
$bar,
&$processed,
&$skipped,
&$errors,
$bar,
$total
) {
foreach ($artworks as $artwork) {
// Update the progress bar with current artwork title
$bar->setMessage($artwork->title ?? "Artwork #{$artwork->id}", 'title');

try {
$this->info(
"\nProcessing artwork: {$artwork->title} (ID: {$artwork->id})",
OutputInterface::VERBOSITY_VERBOSE
);

$imageUrl = $this->buildImageUrl($artwork);
$this->info("Image URL: {$imageUrl}", OutputInterface::VERBOSITY_VERBOSE);

$analysisResults = $this->analyzeImage($artwork, $imageUrl);
$this->processEmbeddings($artwork, $imageUrl, $analysisResults);

$processed++;
} catch (Exception $e) {
$errors[] = [
'id' => $artwork->id,
'title' => $artwork->title,
'error' => $e->getMessage()
];

Log::error('Error processing artwork:', [
'artwork_id' => $artwork->id,
'message' => $e->getMessage(),
'trace' => $e->getTraceAsString()
]);

$this->error(
"\nFailed processing artwork ID {$artwork->id}: {$e->getMessage()}",
OutputInterface::VERBOSITY_VERBOSE
);
}

$bar->advance();

// Update progress message with current statistics
$completedPercentage = ($processed + count($errors)) / $total * 100;
$errorPercentage = count($errors) / $total * 100;
Expand All @@ -139,7 +139,7 @@ public function handle(): int

$this->newLine(2);
$this->info("Analysis completed in {$duration}!", OutputInterface::VERBOSITY_VERBOSE);

$this->table(
['Component', 'Status'],
[
Expand Down Expand Up @@ -245,7 +245,7 @@ protected function processEmbeddings(
"Image embedding response type: " . gettype($imageEmbeddingArray),
OutputInterface::VERBOSITY_VERBOSE
);

if (is_array($imageEmbeddingArray)) {
$this->info(
"Image embedding array count: " . count($imageEmbeddingArray),
Expand Down Expand Up @@ -313,4 +313,4 @@ protected function saveTextEmbeddings(
]
);
}
}
}

0 comments on commit bbf65af

Please sign in to comment.