Skip to content

Commit

Permalink
Updating queue policies so that they go through faster
Browse files Browse the repository at this point in the history
  • Loading branch information
ok200paul committed Sep 30, 2024
1 parent e3e7365 commit 6941e17
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
10 changes: 5 additions & 5 deletions app/Console/Commands/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use App\Models\Team;
use App\Models\TeamServiceTeam;
use App\Models\VoucherSet;
use App\Services\VoucherSetService;
use Illuminate\Console\Command;

class TestCommand extends Command
Expand All @@ -27,12 +29,10 @@ class TestCommand extends Command
*/
public function handle()
{
$voucherSet = VoucherSet::find('9d2129f4-befa-4702-950d-7d3342717462');

$team = Team::factory()->createQuietly();
$isValid = VoucherSetService::validateVoucherSetDenominations($voucherSet);

TeamServiceTeam::factory()->createQuietly([
'team_id' => 1,
'service_team_id' => $team->id,
]);
dd($isValid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,9 @@ public function handle(): int


VoucherSetService::collateVoucherSetAggregates(voucherSet: $voucherSet);

$voucherSet->refresh();



if (!$voucherSet->is_denomination_valid) {

Expand Down
8 changes: 8 additions & 0 deletions app/Jobs/Vouchers/GenerateStorageVoucherQrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ public function __construct(public Voucher $voucher) {}
*/
public function handle(): void
{

if(!isset($this->voucher->voucher_short_code) || is_null($this->voucher->voucher_short_code))
{
self::dispatch(new GenerateStorageVoucherQrCode($this->voucher))->delay(now()->addMinutes(14));
return;
}


$redeemUrl = URL::to('/redeem/' . $this->voucher->voucher_set_id . '/' . $this->voucher->id);

/**
Expand Down
4 changes: 1 addition & 3 deletions app/Listeners/Vouchers/HandleVoucherWasCreatedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ public function __construct() {}
public function handle(VoucherWasCreated $event): void
{
dispatch(new AssignUniqueShortCodeToVoucherJob($event->voucher));

dispatch(new CollateVoucherAggregatesJob($event->voucher));

$voucherSet = VoucherSet::find($event->voucher->voucher_set_id);

if ($voucherSet) {

dispatch(new CollateVoucherSetAggregatesJob($voucherSet));

}

if (config('app.env') != 'testing') {
Expand Down

0 comments on commit 6941e17

Please sign in to comment.