Skip to content

Commit

Permalink
accept codeshares in flightnumber endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Aug 25, 2024
1 parent c226f1d commit 4c47edd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions go/api/data/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}
}
Expand Down

0 comments on commit 4c47edd

Please sign in to comment.