From 5a8b92de5b7d6a629aa42f7f6d2a07ae729e25c5 Mon Sep 17 00:00:00 2001 From: Dillon Ngo Date: Thu, 15 Jan 2026 03:57:08 +0800 Subject: [PATCH] 1688 PO Automation Project --- .../V2/ETLPurchaseOrderTransactionV2CommandJob.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Classes/Jobs/Commands/V2/ETLPurchaseOrderTransactionV2CommandJob.php b/app/Classes/Jobs/Commands/V2/ETLPurchaseOrderTransactionV2CommandJob.php index ca9cbba1..6166646d 100644 --- a/app/Classes/Jobs/Commands/V2/ETLPurchaseOrderTransactionV2CommandJob.php +++ b/app/Classes/Jobs/Commands/V2/ETLPurchaseOrderTransactionV2CommandJob.php @@ -77,7 +77,18 @@ class ETLPurchaseOrderTransactionV2CommandJob implements ShouldQueue (App()->make(ETLPDFPurchaseOrderClaudeProcessor::class))->execute($this->files, $this->bookingId, $this->batchIndex !== 1, $this->isLast); - $finished = Cache::increment('etl_finished_jobs_' . $this->groupId); + $cacheKey = 'etl_finished_jobs_' . $this->groupId; + $lockKey = $cacheKey . '_lock'; + $finished = 0; + + Cache::lock($lockKey, 10)->block(5, function () use ($cacheKey, &$finished) { + // Get current counter (default 0) + $current = Cache::get($cacheKey, 0); + $finished = (int)$current + 1; + + // Save updated counter + Cache::put($cacheKey, $finished, 3600); + }); Log::info('ETL job finished for group ' . $this->groupId, [ 'batch_index' => $this->batchIndex,