Skip to content

Commit

Permalink
Fix eligible Gander controllers being removed during quarterly roster…
Browse files Browse the repository at this point in the history
… update
  • Loading branch information
CalumTowers committed Jan 2, 2025
1 parent 66e04b9 commit 5ba34ce
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions app/Console/Commands/Roster/UpdateRoster.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function handle()
$this->fromDate = Carbon::parse($this->argument('fromDate'))->startOfDay();
$this->toDate = Carbon::parse($this->argument('toDate'))->endOfDay();

$eligible = Atc::with(['account.states'])
$meetHourRequirement = Atc::with(['account.states'])
->select(['networkdata_atc.account_id'])
->whereBetween('disconnected_at', [$this->fromDate, $this->toDate])
->accountIsPartOfUk()
Expand All @@ -37,32 +37,32 @@ public function handle()
->pluck('account_id');

// Automatically mark those on the Gander Oceanic roster as eligible
$eligible->push(
$eligible = $meetHourRequirement->merge(
Http::get(config('services.gander-oceanic.api.base').'/roster')
->collect()
->where('active', true)
->pluck('cid')
->toArray()
);
->flatten()
)->unique();

// On the roster, do not need to be on...
Roster::withoutGlobalScopes()
->whereNotIn('account_id', $eligible->flatten())
->whereNotIn('account_id', $eligible)
->get()
->each
->remove();

// On an ATC waiting list, not on the roster, need to be removed...
WaitingListAccount::whereIn('list_id',
WaitingList::where('department', WaitingList::ATC_DEPARTMENT)->get('id')
)->whereNotIn('account_id', $eligible->flatten())
)->whereNotIn('account_id', $eligible)
->get()
->each
->delete();

// Not on the roster, need to be on...
Roster::upsert(
$eligible->flatten()->map(fn ($value) => ['account_id' => $value])->toArray(),
$eligible->map(fn ($value) => ['account_id' => $value])->toArray(),
['account_id']
);

Expand Down

0 comments on commit 5ba34ce

Please sign in to comment.