refactor: embed film data directly in batch messages
Avoid re-parsing the entire CSV file in each batch handler by including the film data in the message payload itself. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,11 +56,18 @@ readonly class ProcessImportMessageHandler
|
||||
$import->setStatus(Import::STATUS_PROCESSING);
|
||||
$this->em->flush();
|
||||
|
||||
for ($i = 0; $i < $totalBatches; $i++) {
|
||||
$batches = array_chunk($ltbxdMovies, self::BATCH_SIZE);
|
||||
foreach ($batches as $batch) {
|
||||
$films = array_map(fn ($movie) => [
|
||||
'name' => $movie->getName(),
|
||||
'year' => $movie->getYear(),
|
||||
'ltbxdUri' => $movie->getLtbxdUri(),
|
||||
'date' => $movie->getDate()->format('Y-m-d'),
|
||||
], $batch);
|
||||
|
||||
$this->bus->dispatch(new ImportFilmsBatchMessage(
|
||||
importId: $import->getId(),
|
||||
offset: $i * self::BATCH_SIZE,
|
||||
limit: self::BATCH_SIZE,
|
||||
films: $films,
|
||||
));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
|
||||
Reference in New Issue
Block a user