|
2 | 2 |
|
3 | 3 | namespace Biigle\Modules\Sync\Jobs;
|
4 | 4 |
|
5 |
| -use Biigle\ImageAnnotation; |
| 5 | +use Biigle\Image; |
6 | 6 | use Biigle\Jobs\Job;
|
7 | 7 | use Biigle\Jobs\ProcessNewVolumeFiles;
|
8 |
| -use Biigle\Modules\Largo\Jobs\GenerateImageAnnotationPatch; |
9 |
| -use Biigle\Modules\Largo\Jobs\GenerateVideoAnnotationPatch; |
10 |
| -use Biigle\VideoAnnotation; |
| 8 | +use Biigle\Modules\Largo\Jobs\ProcessAnnotatedImage; |
| 9 | +use Biigle\Modules\Largo\Jobs\ProcessAnnotatedVideo; |
| 10 | +use Biigle\Video; |
11 | 11 | use Biigle\Volume;
|
12 | 12 | use Illuminate\Contracts\Queue\ShouldQueue;
|
13 | 13 | use Illuminate\Queue\InteractsWithQueue;
|
@@ -47,24 +47,28 @@ public function handle()
|
47 | 47 | ProcessNewVolumeFiles::dispatch($volume);
|
48 | 48 | });
|
49 | 49 |
|
50 |
| - if (class_exists(GenerateImageAnnotationPatch::class)) { |
51 |
| - ImageAnnotation::join('images', 'images.id', '=', 'image_annotations.image_id') |
52 |
| - ->whereIn('images.volume_id', $this->ids) |
53 |
| - ->select('image_annotations.id') |
54 |
| - ->eachById(function ($annotation) { |
55 |
| - GenerateImageAnnotationPatch::dispatch($annotation) |
| 50 | + // Give the ProcessNewVolumeFiles jobs a head start so the file thumbnails are |
| 51 | + // generated (mostly) before the annotation thumbnails. |
| 52 | + $delay = now()->addSeconds(30); |
| 53 | + |
| 54 | + if (class_exists(ProcessAnnotatedImage::class)) { |
| 55 | + Image::whereIn('images.volume_id', $this->ids) |
| 56 | + ->whereHas('annotations') |
| 57 | + ->eachById(function ($image) use ($delay) { |
| 58 | + ProcessAnnotatedImage::dispatch($image) |
| 59 | + ->delay($delay) |
56 | 60 | ->onQueue(config('largo.generate_annotation_patch_queue'));
|
57 |
| - }, 1000, 'image_annotations.id', 'id'); |
| 61 | + }, 1000); |
58 | 62 | }
|
59 | 63 |
|
60 |
| - if (class_exists(GenerateVideoAnnotationPatch::class)) { |
61 |
| - VideoAnnotation::join('videos', 'videos.id', '=', 'video_annotations.video_id') |
62 |
| - ->whereIn('videos.volume_id', $this->ids) |
63 |
| - ->select('video_annotations.id') |
64 |
| - ->eachById(function ($annotation) { |
65 |
| - GenerateVideoAnnotationPatch::dispatch($annotation) |
| 64 | + if (class_exists(ProcessAnnotatedVideo::class)) { |
| 65 | + Video::whereIn('videos.volume_id', $this->ids) |
| 66 | + ->whereHas('annotations') |
| 67 | + ->eachById(function ($video) use ($delay) { |
| 68 | + ProcessAnnotatedVideo::dispatch($video) |
| 69 | + ->delay($delay) |
66 | 70 | ->onQueue(config('largo.generate_annotation_patch_queue'));
|
67 |
| - }, 1000, 'video_annotations.id', 'id'); |
| 71 | + }, 1000); |
68 | 72 | }
|
69 | 73 | }
|
70 | 74 | }
|
0 commit comments