From 5a85cbac3840a887642c86bf1e9186c2601319e6 Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Tue, 24 Feb 2026 15:52:41 +0000 Subject: [PATCH] certs stats --- app/Jobs/GenerateCertificateBatchJob.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/Jobs/GenerateCertificateBatchJob.php b/app/Jobs/GenerateCertificateBatchJob.php index 2787a32be..b5487ba10 100644 --- a/app/Jobs/GenerateCertificateBatchJob.php +++ b/app/Jobs/GenerateCertificateBatchJob.php @@ -51,11 +51,10 @@ public function handle(): void ->with('user') ->orderBy('id'); - // Either no cert yet, or had a generation error (retry) - $query->where(function ($q) { - $q->whereNull('certificate_url') - ->orWhereNotNull('certificate_generation_error'); - }); + // Process only fresh pending rows in bulk. + // Failed rows are tracked in certificate_generation_error and should not be retried endlessly. + $query->whereNull('certificate_url') + ->whereNull('certificate_generation_error'); $rows = $query->limit(self::BATCH_SIZE)->get(); @@ -107,9 +106,8 @@ public function handle(): void $hasMore = Excellence::query() ->where('edition', $this->edition) ->where('type', $this->type) - ->where(function ($q) { - $q->whereNull('certificate_url')->orWhereNotNull('certificate_generation_error'); - }) + ->whereNull('certificate_url') + ->whereNull('certificate_generation_error') ->limit(1) ->exists();