This commit is contained in:
philipp lang 2023-02-22 22:38:48 +01:00
parent 24d65e37c3
commit abc269d6c4
1 changed files with 3 additions and 7 deletions

View File

@ -5,11 +5,8 @@ namespace App\Initialize;
use App\Initialize\Actions\ProcessRedisAction;
use App\Nami\Api\CompleteMemberToRedisJob;
use App\Setting\NamiSettings;
use Illuminate\Bus\Batch;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Bus;
use Illuminate\Support\Facades\Redis;
use Log;
use Lorisleiva\Actions\Concerns\AsAction;
use Zoomyboy\LaravelNami\Api;
use Zoomyboy\LaravelNami\Data\MemberEntry as NamiMemberEntry;
@ -23,15 +20,14 @@ class InitializeMembers
public function handle(Api $api): void
{
$allMembers = collect([]);
Redis::delete('members');
$jobs = $api->search([])->map(function (NamiMemberEntry $member) use ($api) {
return new CompleteMemberToRedisJob($api, $member->groupId, $member->id);
})->toArray();
$batch = Bus::batch($jobs)
->finally(function (Batch $batch) {
Bus::batch($jobs)
->finally(function () {
foreach (Redis::lrange('members', 0, -1) as $data) {
ProcessRedisAction::dispatch(json_decode($data, true));
}
@ -41,7 +37,7 @@ class InitializeMembers
->dispatch();
}
public function asCommand(Command $command): int
public function asCommand(): int
{
$this->handle(app(NamiSettings::class)->login());