From 4c47edd97a9e23bdfd8e84ebf68f598954590204 Mon Sep 17 00:00:00 2001 From: Felix <23635466+its-felix@users.noreply.github.com> Date: Sun, 25 Aug 2024 02:32:04 +0200 Subject: [PATCH] accept codeshares in flightnumber endpoint --- go/api/data/handler.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/go/api/data/handler.go b/go/api/data/handler.go index 9956e33..2e0808f 100644 --- a/go/api/data/handler.go +++ b/go/api/data/handler.go @@ -255,7 +255,7 @@ func (h *Handler) Aircraft(ctx context.Context) ([]Aircraft, error) { return result, err } -func (h *Handler) FlightNumber(ctx context.Context, fn, airport string, d common.LocalDate) (*common.Flight, error) { +func (h *Handler) FlightNumber(ctx context.Context, fnRaw, airport string, d common.LocalDate) (*common.Flight, error) { flights, err := loadJson[[]*common.Flight]( ctx, h, @@ -270,8 +270,13 @@ func (h *Handler) FlightNumber(ctx context.Context, fn, airport string, d common } } + fn, err := common.ParseFlightNumber(fnRaw) + if err != nil { + return nil, err + } + for _, f := range flights { - if f.Number().String() == fn && f.DepartureAirport == airport { + if _, ok := f.CodeShares[fn]; (f.Number() == fn || ok) && f.DepartureAirport == airport { return f, nil } }