From 444fa04458170e3323801762e6c95d3dfbea00ef Mon Sep 17 00:00:00 2001 From: bernardhanna Date: Tue, 24 Feb 2026 10:45:46 +0000 Subject: [PATCH] certs --- app/Jobs/GenerateCertificateBatchJob.php | 6 ++---- app/Jobs/SendCertificateBatchJob.php | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/Jobs/GenerateCertificateBatchJob.php b/app/Jobs/GenerateCertificateBatchJob.php index 045ae1671..28bada924 100644 --- a/app/Jobs/GenerateCertificateBatchJob.php +++ b/app/Jobs/GenerateCertificateBatchJob.php @@ -54,7 +54,7 @@ public function handle(): void ->orWhereNotNull('certificate_generation_error'); }); - $rows = $query->offset($this->offset)->limit(self::BATCH_SIZE)->get(); + $rows = $query->limit(self::BATCH_SIZE)->get(); if ($rows->isEmpty()) { Cache::forget($runningKey); @@ -101,19 +101,17 @@ public function handle(): void } } - $nextOffset = $this->offset + $rows->count(); $hasMore = Excellence::query() ->where('edition', $this->edition) ->where('type', $this->type) ->where(function ($q) { $q->whereNull('certificate_url')->orWhereNotNull('certificate_generation_error'); }) - ->offset($nextOffset) ->limit(1) ->exists(); if ($hasMore && ! Cache::get($cancelledKey)) { - self::dispatch($this->edition, $this->type, $nextOffset); + self::dispatch($this->edition, $this->type, 0); } else { Cache::forget($runningKey); } diff --git a/app/Jobs/SendCertificateBatchJob.php b/app/Jobs/SendCertificateBatchJob.php index d69b8c47b..94f42da1e 100644 --- a/app/Jobs/SendCertificateBatchJob.php +++ b/app/Jobs/SendCertificateBatchJob.php @@ -44,7 +44,7 @@ public function handle(): void ->with('user') ->orderBy('id'); - $rows = $query->offset($this->offset)->limit(self::BATCH_SIZE)->get(); + $rows = $query->limit(self::BATCH_SIZE)->get(); foreach ($rows as $excellence) { $user = $excellence->user; @@ -70,7 +70,6 @@ public function handle(): void } } - $nextOffset = $this->offset + $rows->count(); $hasMore = Excellence::query() ->where('edition', $this->edition) ->where('type', $this->type) @@ -78,12 +77,11 @@ public function handle(): void ->where(function ($q) { $q->whereNull('notified_at')->orWhereNotNull('certificate_sent_error'); }) - ->offset($nextOffset) ->limit(1) ->exists(); if ($hasMore) { - self::dispatch($this->edition, $this->type, $nextOffset); + self::dispatch($this->edition, $this->type, 0); } else { Cache::forget($runningKey); }