Skip to content

Commit

Permalink
fix: Remove old endorsements from Gander Oceanic API
Browse files Browse the repository at this point in the history
  • Loading branch information
CalumTowers committed Dec 6, 2024
1 parent 7453ff1 commit 5e3cd37
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/Console/Commands/Roster/UpdateRosterGanderControllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class UpdateRosterGanderControllers extends Command

protected $description = 'Update the ATC roster based on those within the Gander roster.';

protected int $ganderServiceAccount = 2;

public function handle()
{
$ganderValidatedAccountIds = Http::get(config('services.gander-oceanic.api.base').'/roster')
Expand Down Expand Up @@ -57,8 +59,17 @@ public function handle()
'account_id' => $value,
'endorsable_id' => $positionGroup->id,
'endorsable_type' => PositionGroup::class,
'created_by' => $this->ganderServiceAccount,
]);
});

// Remove accounts added by the service account
// that are no longer in the API feed.
Endorsement::where([
'endorsable_id' => $positionGroup->id,
'endorsable_type' => PositionGroup::class,
'created_by' => $this->ganderServiceAccount,
])->whereNotIn('account_id', $ganderValidatedAccountIds)->delete();
});
}
}

0 comments on commit 5e3cd37

Please sign in to comment.