From b3354e14743db064b4ae758c710e705c199eaeab Mon Sep 17 00:00:00 2001 From: philipp lang Date: Thu, 2 May 2024 21:08:48 +0200 Subject: [PATCH] Mod deletion of members when initializing --- app/Initialize/InitializeMembers.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Initialize/InitializeMembers.php b/app/Initialize/InitializeMembers.php index d9db3953..a679b4c7 100644 --- a/app/Initialize/InitializeMembers.php +++ b/app/Initialize/InitializeMembers.php @@ -3,6 +3,7 @@ namespace App\Initialize; use App\Member\Actions\InsertFullMemberAction; +use Log; use App\Member\Data\FullMember; use App\Member\Member; use App\Nami\Api\FullMemberAction; @@ -26,7 +27,13 @@ class InitializeMembers Redis::delete('members'); $memberIds = $api->search($settings->search_params)->map(fn ($member) => $member->id)->toArray(); - Member::remote()->whereNotIn('nami_id', $memberIds)->get()->each->delete(); + foreach (Member::remote()->whereNotIn('nami_id', $memberIds)->get() as $member) { + if ($member->efz !== null || $member->ps_at !== null || $member->more_ps_at !== null) { + Log::error('Mitglied ' . $member->id . ' wird nicht gelöscht werden.'); + continue; + } + $member->delete(); + } $jobs = $api->search($settings->search_params)->map(function (NamiMemberEntry $member) use ($api) { return FullMemberAction::makeJob($api, $member->groupId, $member->id, 'members');