-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Facades\EntityFacade; | ||
use App\Models\Membership; | ||
use App\Traits\HandlesJobsFailuresTrait; | ||
use Illuminate\Bus\Batchable; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Mockery\Exception; | ||
|
||
class RestoreFederation implements ShouldQueue | ||
{ | ||
use Batchable, Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
use HandlesJobsFailuresTrait; | ||
|
||
public Membership $membership; | ||
|
||
/** | ||
* Create a new job instance. | ||
*/ | ||
public function __construct(Membership $membership) | ||
{ | ||
$this->membership = $membership; | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
*/ | ||
public function handle(): void | ||
{ | ||
if ($this->batch()->cancelled()) { | ||
$this->fail(new Exception('batch was cancelled')); | ||
} | ||
try { | ||
$federation = $this->membership->federation; | ||
$entity = $this->membership->entity; | ||
EntityFacade::saveMetadataToFederationFolder($entity->id, $federation->id); | ||
|
||
} catch (Exception $e) { | ||
$this->fail($e); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
database/migrations/2024_07_26_083341_create_job_batches_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class extends Migration | ||
{ | ||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
Schema::create('job_batches', function (Blueprint $table) { | ||
$table->string('id')->primary(); | ||
$table->string('name'); | ||
$table->integer('total_jobs'); | ||
$table->integer('pending_jobs'); | ||
$table->integer('failed_jobs'); | ||
$table->longText('failed_job_ids'); | ||
$table->mediumText('options')->nullable(); | ||
$table->integer('cancelled_at')->nullable(); | ||
$table->integer('created_at'); | ||
$table->integer('finished_at')->nullable(); | ||
}); | ||
} | ||
|
||
/** | ||
* Reverse the migrations. | ||
*/ | ||
public function down(): void | ||
{ | ||
Schema::dropIfExists('job_batches'); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters