Skip to content

Commit

Permalink
Implement delay to (somewhat) ensure order of processing
Browse files Browse the repository at this point in the history
  • Loading branch information
mzur committed Jan 18, 2024
1 parent 7a7aec9 commit 36ef086
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions app/Jobs/CloneImagesOrVideos.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,26 @@ public function postProcessCloning($volume)
{
ProcessNewVolumeFiles::dispatch($volume);

// Give the ProcessNewVolumeFiles job a head start so the file thumbnails are
// generated (mostly) before the annotation thumbnails.
$delay = now()->addSeconds(30);

if (class_exists(ProcessAnnotatedImage::class)) {
$volume->images()->whereHas('annotations')->eachById(function ($image) {
ProcessAnnotatedImage::dispatch($image)
->onQueue(config('largo.generate_annotation_patch_queue'));
});
$volume->images()->whereHas('annotations')
->eachById(function ($image) use ($delay) {
ProcessAnnotatedImage::dispatch($image)
->delay($delay)
->onQueue(config('largo.generate_annotation_patch_queue'));
});
}

if (class_exists(ProcessAnnotatedVideo::class)) {
$volume->videos()->whereHas('annotations')->eachById(function ($video) {
ProcessAnnotatedVideo::dispatch($video)
->onQueue(config('largo.generate_annotation_patch_queue'));
});
$volume->videos()
->whereHas('annotations')->eachById(function ($video) use ($delay) {
ProcessAnnotatedVideo::dispatch($video)
->delay($delay)
->onQueue(config('largo.generate_annotation_patch_queue'));
});
}
}

Expand Down

0 comments on commit 36ef086

Please sign in to comment.