From 7877f57a227625d61d1e73edc646d47075e6497c Mon Sep 17 00:00:00 2001 From: Philipp Lang Date: Thu, 6 Jul 2023 14:29:35 +0200 Subject: [PATCH] Remove deleted members on pull --- app/Initialize/InitializeMembers.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index 1e9d61ac..d9db3953 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -4,6 +4,7 @@ namespace App\Initialize; use App\Member\Actions\InsertFullMemberAction; use App\Member\Data\FullMember; +use App\Member\Member; use App\Nami\Api\FullMemberAction; use App\Setting\NamiSettings; use Illuminate\Support\Facades\Bus; @@ -24,6 +25,9 @@ class InitializeMembers $settings = app(NamiSettings::class); Redis::delete('members'); + $memberIds = $api->search($settings->search_params)->map(fn ($member) => $member->id)->toArray(); + Member::remote()->whereNotIn('nami_id', $memberIds)->get()->each->delete(); + $jobs = $api->search($settings->search_params)->map(function (NamiMemberEntry $member) use ($api) { return FullMemberAction::makeJob($api, $member->groupId, $member->id, 'members'); })->toArray();