2023-02-13 00:14:51 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Nami\Api;
|
|
|
|
|
|
|
|
use Illuminate\Bus\Batchable;
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
use Illuminate\Foundation\Events\Dispatchable;
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
use Illuminate\Support\Facades\Redis;
|
2023-02-13 15:56:20 +01:00
|
|
|
use Log;
|
2023-02-13 00:14:51 +01:00
|
|
|
use Zoomyboy\LaravelNami\Api;
|
|
|
|
|
|
|
|
class CompleteMemberToRedisJob implements ShouldQueue
|
|
|
|
{
|
|
|
|
use Batchable;
|
|
|
|
use Dispatchable;
|
|
|
|
use InteractsWithQueue;
|
|
|
|
use Queueable;
|
|
|
|
use SerializesModels;
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
private Api $api,
|
|
|
|
private int $groupId,
|
|
|
|
private int $memberId,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handle(): void
|
|
|
|
{
|
2023-02-13 01:06:04 +01:00
|
|
|
if ($this->batch()->cancelled()) {
|
2023-02-13 15:56:20 +01:00
|
|
|
Log::debug('Cancelling batch');
|
|
|
|
|
2023-02-13 01:06:04 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-02-13 00:14:51 +01:00
|
|
|
Redis::rpush('members', collect([
|
|
|
|
'member' => MemberAction::run($this->api, $this->groupId, $this->memberId),
|
|
|
|
'memberships' => MembershipsOfAction::run($this->api, $this->memberId),
|
|
|
|
'courses' => CoursesOfAction::run($this->api, $this->memberId),
|
|
|
|
])->toJson());
|
|
|
|
}
|
|
|
|
}
|