Updated scheduled tasks
This commit is contained in:
@@ -78,6 +78,28 @@ class GetAircraftInfoForArrivedFlights extends Command
|
||||
$this->applyAndNotify($flight, $data, $airlineCode, $flightNumber);
|
||||
}
|
||||
|
||||
protected function splitFlightNumber(UserFlight $flight): array
|
||||
{
|
||||
$raw = strtoupper($flight->flight_number);
|
||||
$airline = $flight->airline;
|
||||
|
||||
// Preferred: anchor on the airline's known codes rather than guessing.
|
||||
foreach (array_filter([$airline?->iata_code, $airline?->icao_code]) as $code) {
|
||||
$code = strtoupper($code);
|
||||
if (str_starts_with($raw, $code) && preg_match('/^\d+$/', substr($raw, strlen($code)))) {
|
||||
return [$code, substr($raw, strlen($code))];
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: regex guess.
|
||||
// Covers: letter+digit (J2), digit+letter (9K, 4U), and 2-3 letter codes (AA, DAL).
|
||||
if (preg_match('/^([A-Z]\d|\d[A-Z]|[A-Z]{2,3})(\d+)$/', $raw, $matches)) {
|
||||
return [$matches[1], $matches[2]];
|
||||
}
|
||||
|
||||
return [null, null];
|
||||
}
|
||||
|
||||
protected function notifyLookupFailed(UserFlight $flight, string $airlineCode, string $flightNumber): void
|
||||
{
|
||||
Notification::create([
|
||||
|
||||
Reference in New Issue
Block a user