Skip to content

Commit

Permalink
Merge pull request #707 from biigle/patch-1
Browse files Browse the repository at this point in the history
Allow the configuration of a queue for the ProcessNewVideo job
  • Loading branch information
mzur authored Nov 29, 2023
2 parents aca6db7 + a789b0d commit 169200e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/Jobs/ProcessNewVolumeFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function handle()
if ($this->volume->isImageVolume()) {
$query->eachById([ProcessNewImage::class, 'dispatch']);
} else {
$query->eachById([ProcessNewVideo::class, 'dispatch']);
$queue = config('videos.process_new_video_queue');
$query->eachById(fn ($v) => ProcessNewVideo::dispatch($v)->onQueue($queue));
}
}
}
12 changes: 12 additions & 0 deletions tests/php/Jobs/ProcessNewVolumeFilesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,16 @@ public function testHandleVideosWithOnly()

Queue::assertNotPushed(ProcessNewVideo::class, fn ($job) => $job->video->id === $v2->id);
}

public function testHandleVideosQueue()
{
config(['videos.process_new_video_queue' => 'low']);
$volume = VolumeTest::create(['media_type_id' => MediaType::videoId()]);
$v1 = VideoTest::create(['volume_id' => $volume->id, 'filename' => 'a.mp4']);

Queue::fake();
with(new ProcessNewVolumeFiles($volume))->handle();

Queue::assertPushedOn('low', ProcessNewVideo::class, fn ($job) => $job->video->id === $v1->id);
}
}

0 comments on commit 169200e

Please sign in to comment.