From 4accc5441823a936929387b637f197360484fbf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrei=20Ioni=C8=9B=C4=83?= Date: Mon, 2 Dec 2024 00:02:38 +0200 Subject: [PATCH] fix: import (#137) --- app/Jobs/DeleteTemporaryTableData.php | 15 ++++++++++++++- app/Jobs/PersistTemporaryTableData.php | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/app/Jobs/DeleteTemporaryTableData.php b/app/Jobs/DeleteTemporaryTableData.php index 7aceebb..37e941b 100644 --- a/app/Jobs/DeleteTemporaryTableData.php +++ b/app/Jobs/DeleteTemporaryTableData.php @@ -6,11 +6,12 @@ use App\Contracts\TemporaryTable; use Exception; +use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; use Illuminate\Support\Facades\DB; -class DeleteTemporaryTableData implements ShouldQueue +class DeleteTemporaryTableData implements ShouldQueue, ShouldBeUnique { use Queueable; @@ -18,6 +19,13 @@ class DeleteTemporaryTableData implements ShouldQueue public int $electionId; + /** + * The number of seconds after which the job's unique lock will be released. + * + * @var int + */ + public $uniqueFor = 45; + /** * Create a new job instance. */ @@ -42,4 +50,9 @@ public function handle(): void ->where('election_id', $this->electionId) ->delete(); } + + public function uniqueId(): string + { + return "delete-temporary-table-data:{$this->model}"; + } } diff --git a/app/Jobs/PersistTemporaryTableData.php b/app/Jobs/PersistTemporaryTableData.php index 5544cbc..1e30879 100644 --- a/app/Jobs/PersistTemporaryTableData.php +++ b/app/Jobs/PersistTemporaryTableData.php @@ -7,11 +7,12 @@ use App\Contracts\TemporaryTable; use App\Jobs\Middleware\RateLimitSchedulableJobMiddleware; use Exception; +use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Queue\Queueable; use Illuminate\Support\Facades\DB; -class PersistTemporaryTableData implements ShouldQueue +class PersistTemporaryTableData implements ShouldQueue, ShouldBeUnique { use Queueable; @@ -19,6 +20,13 @@ class PersistTemporaryTableData implements ShouldQueue public ?int $electionId; + /** + * The number of seconds after which the job's unique lock will be released. + * + * @var int + */ + public $uniqueFor = 45; + /** * Create a new job instance. */ @@ -72,4 +80,9 @@ public function middleware(): array new RateLimitSchedulableJobMiddleware('persist-temporary-table-data'), ]; } + + public function uniqueId(): string + { + return "persist-temporary-table-data:{$this->model}"; + } }