onQueue('ai-batch'); } public function handle(): void { // Get pending and scheduled tasks ready for processing $tasks = ContentTask::query() ->where(function ($query) { $query->where('status', ContentTask::STATUS_PENDING) ->orWhere(function ($q) { $q->where('status', ContentTask::STATUS_SCHEDULED) ->where('scheduled_for', '<=', now()); }); }) ->where('priority', $this->priority) ->orderBy('created_at') ->limit($this->batchSize) ->get(); if ($tasks->isEmpty()) { Log::info("BatchContentGeneration: No {$this->priority} priority tasks to process"); return; } Log::info("BatchContentGeneration: Processing {$tasks->count()} {$this->priority} priority tasks"); foreach ($tasks as $task) { ProcessContentTask::dispatch($task); } } /** * Get the tags that should be assigned to the job. */ public function tags(): array { return [ 'batch-generation', "priority:{$this->priority}", ]; } }