Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 048bc35

Browse files
committed
Update for new ProcessAnnotatedFile job of biigle/largo
1 parent 4283e41 commit 048bc35

File tree

2 files changed

+25
-27
lines changed

2 files changed

+25
-27
lines changed

src/Jobs/PostprocessVolumeImport.php

+16-18
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
namespace Biigle\Modules\Sync\Jobs;
44

5-
use Biigle\ImageAnnotation;
5+
use Biigle\Image;
66
use Biigle\Jobs\Job;
77
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;
1111
use Biigle\Volume;
1212
use Illuminate\Contracts\Queue\ShouldQueue;
1313
use Illuminate\Queue\InteractsWithQueue;
@@ -47,24 +47,22 @@ public function handle()
4747
ProcessNewVolumeFiles::dispatch($volume);
4848
});
4949

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+
if (class_exists(ProcessAnnotatedImage::class)) {
51+
Image::whereIn('images.volume_id', $this->ids)
52+
->whereHas('annotations')
53+
->eachById(function ($image) {
54+
ProcessAnnotatedImage::dispatch($image)
5655
->onQueue(config('largo.generate_annotation_patch_queue'));
57-
}, 1000, 'image_annotations.id', 'id');
56+
}, 1000);
5857
}
5958

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)
59+
if (class_exists(ProcessAnnotatedVideo::class)) {
60+
Video::whereIn('videos.volume_id', $this->ids)
61+
->whereHas('annotations')
62+
->eachById(function ($video) {
63+
ProcessAnnotatedVideo::dispatch($video)
6664
->onQueue(config('largo.generate_annotation_patch_queue'));
67-
}, 1000, 'video_annotations.id', 'id');
65+
}, 1000);
6866
}
6967
}
7068
}

tests/Jobs/PostprocessVolumeImportTest.php

+9-9
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace Biigle\Tests\Modules\Sync\Jobs;
44

55
use Biigle\Jobs\ProcessNewVolumeFiles;
6-
use Biigle\Modules\Largo\Jobs\GenerateImageAnnotationPatch;
7-
use Biigle\Modules\Largo\Jobs\GenerateVideoAnnotationPatch;
6+
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedImage;
7+
use Biigle\Modules\Largo\Jobs\ProcessAnnotatedVideo;
88
use Biigle\Modules\Sync\Jobs\PostprocessVolumeImport;
99
use Biigle\Tests\ImageAnnotationTest;
1010
use Biigle\Tests\ImageTest;
@@ -20,34 +20,34 @@ public function testHandleVolumeImages()
2020
$job = new PostprocessVolumeImport(collect([$image->volume]));
2121
$job->handle();
2222
Queue::assertPushed(ProcessNewVolumeFiles::class);
23-
Queue::assertNotPushed(GenerateImageAnnotationPatch::class);
23+
Queue::assertNotPushed(ProcessAnnotatedImage::class);
2424
}
2525

2626
public function testHandleImageAnnotationPatches()
2727
{
28-
if (!class_exists(GenerateImageAnnotationPatch::class)) {
29-
$this->markTestSkipped('Requires '.GenerateImageAnnotationPatch::class);
28+
if (!class_exists(ProcessAnnotatedImage::class)) {
29+
$this->markTestSkipped('Requires '.ProcessAnnotatedImage::class);
3030
}
3131

3232
$annotation = ImageAnnotationTest::create();
3333
$job = new PostprocessVolumeImport(collect([$annotation->image->volume]));
3434
$job->handle();
3535
// One job for the creation of the annotation and one job by
3636
// PostprocessVolumeImport.
37-
$this->assertCount(2, Queue::pushed(GenerateImageAnnotationPatch::class));
37+
$this->assertCount(2, Queue::pushed(ProcessAnnotatedImage::class));
3838
}
3939

4040
public function testHandleVideoAnnotationPatches()
4141
{
42-
if (!class_exists(GenerateVideoAnnotationPatch::class)) {
43-
$this->markTestSkipped('Requires '.GenerateVideoAnnotationPatch::class);
42+
if (!class_exists(ProcessAnnotatedVideo::class)) {
43+
$this->markTestSkipped('Requires '.ProcessAnnotatedVideo::class);
4444
}
4545

4646
$annotation = VideoAnnotationTest::create();
4747
$job = new PostprocessVolumeImport(collect([$annotation->video->volume]));
4848
$job->handle();
4949
// One job for the creation of the annotation and one job by
5050
// PostprocessVolumeImport.
51-
$this->assertCount(2, Queue::pushed(GenerateVideoAnnotationPatch::class));
51+
$this->assertCount(2, Queue::pushed(ProcessAnnotatedVideo::class));
5252
}
5353
}

0 commit comments

Comments
 (0)