Skip to content

Commit 36ef086

Browse files
committed
Implement delay to (somewhat) ensure order of processing
1 parent 7a7aec9 commit 36ef086

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

app/Jobs/CloneImagesOrVideos.php

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,26 @@ public function postProcessCloning($volume)
162162
{
163163
ProcessNewVolumeFiles::dispatch($volume);
164164

165+
// Give the ProcessNewVolumeFiles job a head start so the file thumbnails are
166+
// generated (mostly) before the annotation thumbnails.
167+
$delay = now()->addSeconds(30);
168+
165169
if (class_exists(ProcessAnnotatedImage::class)) {
166-
$volume->images()->whereHas('annotations')->eachById(function ($image) {
167-
ProcessAnnotatedImage::dispatch($image)
168-
->onQueue(config('largo.generate_annotation_patch_queue'));
169-
});
170+
$volume->images()->whereHas('annotations')
171+
->eachById(function ($image) use ($delay) {
172+
ProcessAnnotatedImage::dispatch($image)
173+
->delay($delay)
174+
->onQueue(config('largo.generate_annotation_patch_queue'));
175+
});
170176
}
171177

172178
if (class_exists(ProcessAnnotatedVideo::class)) {
173-
$volume->videos()->whereHas('annotations')->eachById(function ($video) {
174-
ProcessAnnotatedVideo::dispatch($video)
175-
->onQueue(config('largo.generate_annotation_patch_queue'));
176-
});
179+
$volume->videos()
180+
->whereHas('annotations')->eachById(function ($video) use ($delay) {
181+
ProcessAnnotatedVideo::dispatch($video)
182+
->delay($delay)
183+
->onQueue(config('largo.generate_annotation_patch_queue'));
184+
});
177185
}
178186
}
179187

0 commit comments

Comments
 (0)