Skip to content

Commit 58f2341

Browse files
committed
Immediately mark attachment as optimized
Don't wait for the whole batch completed.
1 parent 8d16b18 commit 58f2341

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/ImageOptimizeCommand.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ public function run($_args, $assocArgs = [])
4343
$optimizerChain = OptimizerChainFactory::create();
4444
$optimizerChain->useLogger($logger);
4545

46-
array_map(function (string $imagePath) use ($optimizerChain) {
47-
$optimizerChain->optimize($imagePath);
48-
}, ImageRepository::pathsFor(...$attachmentIds));
46+
// TODO: Extract to its own class.
47+
array_map(function (int $attachmentId) use ($optimizerChain) {
48+
array_map(function (string $imagePath) use ($optimizerChain) {
49+
$optimizerChain->optimize($imagePath);
50+
}, ImageRepository::pathsFor($attachmentId));
4951

50-
AttachmentRepository::markAsOptimized(...$attachmentIds);
52+
AttachmentRepository::markAsOptimized($attachmentId);
53+
}, $attachmentIds);
5154

5255
$logger->notice(
5356
sprintf('%d attachment(s) optimized', count($attachmentIds))

0 commit comments

Comments
 (0)