optimizations
This commit is contained in:
47
app/Jobs/RefreshCollectionQualityJob.php
Normal file
47
app/Jobs/RefreshCollectionQualityJob.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Jobs;
|
||||
|
||||
use App\Models\Collection;
|
||||
use App\Models\User;
|
||||
use App\Services\CollectionWorkflowService;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
final class RefreshCollectionQualityJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable;
|
||||
use InteractsWithQueue;
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
public int $tries = 3;
|
||||
|
||||
/** @var array<int, int> */
|
||||
public array $backoff = [30, 180, 600];
|
||||
|
||||
public function __construct(
|
||||
public readonly int $collectionId,
|
||||
public readonly ?int $actorUserId = null,
|
||||
) {
|
||||
$this->onQueue((string) config('collections.v5.queue.name', 'collections'));
|
||||
}
|
||||
|
||||
public function handle(CollectionWorkflowService $workflow): void
|
||||
{
|
||||
$collection = Collection::query()->find($this->collectionId);
|
||||
|
||||
if (! $collection) {
|
||||
return;
|
||||
}
|
||||
|
||||
$actor = $this->actorUserId ? User::query()->find($this->actorUserId) : null;
|
||||
|
||||
$workflow->qualityRefresh($collection->loadMissing('user'), $actor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user