Skip to content

Commit 7a7aec9

Browse files
committed
Update for new ProcessAnnotatedFile job of biigle/largo
1 parent f2a618b commit 7a7aec9

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

app/Jobs/CloneImagesOrVideos.php

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
use Biigle\ImageAnnotation;
99
use Biigle\ImageAnnotationLabel;
1010
use Biigle\ImageLabel;
11-
use Biigle\Modules\Largo\Jobs\GenerateImageAnnotationPatch;
12-
use Biigle\Modules\Largo\Jobs\GenerateVideoAnnotationPatch;
11+
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedImage;
12+
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedVideo;
1313
use Biigle\Project;
1414
use Biigle\Traits\ChecksMetadataStrings;
1515
use Biigle\Video;
@@ -162,24 +162,18 @@ public function postProcessCloning($volume)
162162
{
163163
ProcessNewVolumeFiles::dispatch($volume);
164164

165-
if (class_exists(GenerateImageAnnotationPatch::class)) {
166-
ImageAnnotation::join('images', 'images.id', '=', 'image_annotations.image_id')
167-
->where('images.volume_id', "=", $volume->id)
168-
->select('image_annotations.id')
169-
->eachById(function ($annotation) {
170-
GenerateImageAnnotationPatch::dispatch($annotation)
171-
->onQueue(config('largo.generate_annotation_patch_queue'));
172-
}, 1000, 'image_annotations.id', 'id');
165+
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+
});
173170
}
174171

175-
if (class_exists(GenerateVideoAnnotationPatch::class)) {
176-
VideoAnnotation::join('videos', 'videos.id', '=', 'video_annotations.video_id')
177-
->where('videos.volume_id', "=", $volume->id)
178-
->select('video_annotations.id')
179-
->eachById(function ($annotation) {
180-
GenerateVideoAnnotationPatch::dispatch($annotation)
181-
->onQueue(config('largo.generate_annotation_patch_queue'));
182-
}, 1000, 'video_annotations.id', 'id');
172+
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+
});
183177
}
184178
}
185179

tests/php/Jobs/CloneImagesOrVideosTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use Biigle\Jobs\CloneImagesOrVideos;
66
use Biigle\Jobs\ProcessNewVolumeFiles;
77
use Biigle\MediaType;
8-
use Biigle\Modules\Largo\Jobs\GenerateImageAnnotationPatch;
9-
use Biigle\Modules\Largo\Jobs\GenerateVideoAnnotationPatch;
8+
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedImage;
9+
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedVideo;
1010
use Biigle\Tests\ImageAnnotationLabelTest;
1111
use Biigle\Tests\ImageAnnotationTest;
1212
use Biigle\Tests\ImageLabelTest;
@@ -616,13 +616,13 @@ public function testHandleVolumeImages()
616616
(new CloneImagesOrVideos($request, $copy))->handle();
617617

618618
Queue::assertPushed(ProcessNewVolumeFiles::class);
619-
Queue::assertNotPushed(GenerateImageAnnotationPatch::class);
619+
Queue::assertNotPushed(ProcessAnnotatedImage::class);
620620
}
621621

622622
public function testHandleImageAnnotationPatches()
623623
{
624-
if (!class_exists(GenerateImageAnnotationPatch::class)) {
625-
$this->markTestSkipped('Requires '.GenerateImageAnnotationPatch::class);
624+
if (!class_exists(ProcessAnnotatedImage::class)) {
625+
$this->markTestSkipped('Requires '.ProcessAnnotatedImage::class);
626626
}
627627

628628
// The target project.
@@ -647,15 +647,15 @@ public function testHandleImageAnnotationPatches()
647647
]);
648648
(new CloneImagesOrVideos($request, $copy))->handle();
649649

650-
// One job for the creation of the annotation and one job for GenerateImageAnnotationPatch
650+
// One job for the creation of the annotation and one job for ProcessAnnotatedImage
651651
Queue::assertPushed(ProcessNewVolumeFiles::class);
652-
Queue::assertPushed(GenerateImageAnnotationPatch::class);
652+
Queue::assertPushed(ProcessAnnotatedImage::class);
653653
}
654654

655655
public function testHandleVideoAnnotationPatches()
656656
{
657-
if (!class_exists(GenerateVideoAnnotationPatch::class)) {
658-
$this->markTestSkipped('Requires '.GenerateVideoAnnotationPatch::class);
657+
if (!class_exists(ProcessAnnotatedVideo::class)) {
658+
$this->markTestSkipped('Requires '.ProcessAnnotatedVideo::class);
659659
}
660660

661661
// The target project.
@@ -680,8 +680,8 @@ public function testHandleVideoAnnotationPatches()
680680
]);
681681
(new CloneImagesOrVideos($request, $copy))->handle();
682682

683-
// One job for the creation of the annotation and one job for GenerateVideoAnnotationPatch
683+
// One job for the creation of the annotation and one job for ProcessAnnotatedVideo
684684
Queue::assertPushed(ProcessNewVolumeFiles::class);
685-
Queue::assertPushed(GenerateVideoAnnotationPatch::class);
685+
Queue::assertPushed(ProcessAnnotatedVideo::class);
686686
}
687687
}

0 commit comments

Comments
 (0)