Fixed arrival processing
This commit is contained in:
@@ -43,22 +43,21 @@ class GetAircraftInfoForArrivedFlights extends Command
|
|||||||
|
|
||||||
protected function processFlight(UserFlight $flight): void
|
protected function processFlight(UserFlight $flight): void
|
||||||
{
|
{
|
||||||
preg_match('/^([A-Z]{2,3})(\d+)$/i', $flight->flight_number, $matches);
|
[$airlineCode, $flightNumber] = $this->splitFlightNumber($flight);
|
||||||
|
|
||||||
// Case 1: unparseable flight number on our end — disable and move on, no notification.
|
// Case 1: unparseable flight number on our end — disable and move on, no notification.
|
||||||
if (empty($matches)) {
|
if ($airlineCode === null) {
|
||||||
$this->warn("Could not parse flight number: {$flight->flight_number}");
|
$this->warn("Could not parse flight number: {$flight->flight_number}");
|
||||||
Log::warning("Could not parse flight number for auto-update", ['flight_id' => $flight->id, 'flight_number' => $flight->flight_number]);
|
Log::warning("Could not parse flight number for auto-update", ['flight_id' => $flight->id, 'flight_number' => $flight->flight_number]);
|
||||||
$flight->update(['auto_update' => false]);
|
$flight->update(['auto_update' => false]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$airlineCode = strtoupper($matches[1]);
|
|
||||||
$flightNumber = $matches[2];
|
|
||||||
$arrivalDate = $flight->arrival_date->setTimezone($flight->arrivalAirport->timezone);
|
$arrivalDate = $flight->arrival_date->setTimezone($flight->arrivalAirport->timezone);
|
||||||
|
|
||||||
$data = $this->flightStats->fetchFlightData($airlineCode, $flightNumber, $arrivalDate);
|
$data = $this->flightStats->fetchFlightData($airlineCode, $flightNumber, $arrivalDate);
|
||||||
|
|
||||||
|
|
||||||
// Case 2: valid flight number, but the API had nothing for it.
|
// Case 2: valid flight number, but the API had nothing for it.
|
||||||
if (!$data) {
|
if (!$data) {
|
||||||
$this->warn("No flight data returned for {$airlineCode}{$flightNumber}");
|
$this->warn("No flight data returned for {$airlineCode}{$flightNumber}");
|
||||||
@@ -70,6 +69,7 @@ class GetAircraftInfoForArrivedFlights extends Command
|
|||||||
if ($data->departure_iata !== $flight->departureAirport->iata_code ||
|
if ($data->departure_iata !== $flight->departureAirport->iata_code ||
|
||||||
$data->arrival_iata !== $flight->arrivalAirport->iata_code) {
|
$data->arrival_iata !== $flight->arrivalAirport->iata_code) {
|
||||||
$this->warn("Airport mismatch for {$airlineCode}{$flightNumber} — API: {$data->departure_iata}→{$data->arrival_iata}, expected: {$flight->departureAirport->iata_code}→{$flight->arrivalAirport->iata_code}");
|
$this->warn("Airport mismatch for {$airlineCode}{$flightNumber} — API: {$data->departure_iata}→{$data->arrival_iata}, expected: {$flight->departureAirport->iata_code}→{$flight->arrivalAirport->iata_code}");
|
||||||
|
Log::warning("Airport mismatch for {$airlineCode}{$flightNumber} — API: {$data->departure_iata}→{$data->arrival_iata}, expected: {$flight->departureAirport->iata_code}→{$flight->arrivalAirport->iata_code}");
|
||||||
$this->notifyLookupFailed($flight, $airlineCode, $flightNumber);
|
$this->notifyLookupFailed($flight, $airlineCode, $flightNumber);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -153,6 +153,7 @@ class GetAircraftInfoForArrivedFlights extends Command
|
|||||||
$this->info("Updated flight {$airlineCode}{$flightNumber}: " . implode(', ', array_keys($updates)));
|
$this->info("Updated flight {$airlineCode}{$flightNumber}: " . implode(', ', array_keys($updates)));
|
||||||
} else {
|
} else {
|
||||||
$this->info("No changes for {$airlineCode}{$flightNumber}");
|
$this->info("No changes for {$airlineCode}{$flightNumber}");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$flight->update(['auto_update' => false]);
|
$flight->update(['auto_update' => false]);
|
||||||
@@ -229,7 +230,7 @@ class GetAircraftInfoForArrivedFlights extends Command
|
|||||||
{
|
{
|
||||||
$datePart = $showDate ? $time->format($showYear ? 'j M Y, ' : 'j M, ') : '';
|
$datePart = $showDate ? $time->format($showYear ? 'j M Y, ' : 'j M, ') : '';
|
||||||
|
|
||||||
return $datePart . $time->format('g:ia') . ' ' . $time->format('T');
|
return $datePart . $time->format('g:ia');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function describeAircraftType(?Aircraft $from, ?Aircraft $to, ?string $equipmentIata, bool $notFound): string
|
protected function describeAircraftType(?Aircraft $from, ?Aircraft $to, ?string $equipmentIata, bool $notFound): string
|
||||||
|
|||||||
Reference in New Issue
Block a user