Skip to content

Commit

Permalink
Merge pull request #1320 from AndyTWF/request-a-stand-selective-requests
Browse files Browse the repository at this point in the history
fix: consider request time for stand requests
  • Loading branch information
AndyTWF authored May 13, 2023
2 parents 5ba3676 + 0a88bcb commit 5237678
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion app/Allocator/Stand/AbstractArrivalStandAllocator.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Models\Aircraft\Aircraft;
use App\Models\Stand\Stand;
use App\Models\Vatsim\NetworkAircraft;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Query\JoinClause;
Expand Down Expand Up @@ -59,7 +60,17 @@ private function applyBaseOrderingToStandsQuery(Builder $query, NetworkAircraft
->leftJoin('stand_requests as other_stand_requests', function (JoinClause $join) use ($aircraft) {
// Prefer stands that haven't been requested by someone else
$join->on('stands.id', '=', 'other_stand_requests.stand_id')
->on('other_stand_requests.user_id', '<>', $join->raw($aircraft->cid));
->on('other_stand_requests.user_id', '<>', $join->raw($aircraft->cid))
->on(
'other_stand_requests.requested_time',
'>',
$join->raw(
sprintf(
'\'%s\'',
Carbon::now()
)
)
);
})
->orderByRaw('other_stand_requests.id IS NULL')
->inRandomOrder();
Expand Down

0 comments on commit 5237678

Please sign in to comment.