Skip to content

Commit

Permalink
fix: import (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiio authored Dec 1, 2024
1 parent c0b69ef commit 4accc54
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion app/Jobs/DeleteTemporaryTableData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@

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;

public string $model;

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.
*/
Expand All @@ -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}";
}
}
15 changes: 14 additions & 1 deletion app/Jobs/PersistTemporaryTableData.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,26 @@
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;

public string $model;

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.
*/
Expand Down Expand Up @@ -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}";
}
}

0 comments on commit 4accc54

Please sign in to comment.