Skip to content

Commit

Permalink
always combine freshly requested flights
Browse files Browse the repository at this point in the history
  • Loading branch information
its-felix committed Aug 25, 2024
1 parent 9edf0eb commit e56bf12
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions go/cron/action/convert_flight_schedules.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (a *cfsAction) upsertFlights(ctx context.Context, bucket, prefix string, d

for _, f := range flights {
if addedFlight, ok := added[f.Id()]; ok {
if err := combineFlights(addedFlight, f, queryDateRanges); err != nil {
if err := combineFlights(addedFlight, f, true, queryDateRanges); err != nil {
return err
}
} else {
Expand All @@ -156,7 +156,7 @@ func (a *cfsAction) upsertFlights(ctx context.Context, bucket, prefix string, d

for _, f := range existing {
if addedFlight, ok := added[f.Id()]; ok {
if err := combineFlights(addedFlight, f, queryDateRanges); err != nil {
if err := combineFlights(addedFlight, f, false, queryDateRanges); err != nil {
return err
}
} else {
Expand Down Expand Up @@ -325,13 +325,13 @@ func convertFlightSchedulesToFlights(ctx context.Context, queryDate common.Local
return nil
}

func combineFlights(f, other *common.Flight, queryDateRanges common.LocalDateRanges) error {
func combineFlights(f, other *common.Flight, fresh bool, queryDateRanges common.LocalDateRanges) error {
otherQueryDate, err := common.ParseLocalDate(other.DataElements[queryDateId])
if err != nil {
return err
}

if !queryDateRanges.Contains(otherQueryDate) {
if fresh || !queryDateRanges.Contains(otherQueryDate) {
for k, v := range other.DataElements {
if _, ok := f.DataElements[k]; !ok {
f.DataElements[k] = v
Expand All @@ -345,7 +345,7 @@ func combineFlights(f, other *common.Flight, queryDateRanges common.LocalDateRan
return err
}

if !queryDateRanges.Contains(codeShareQueryDate) {
if fresh || !queryDateRanges.Contains(codeShareQueryDate) {
if dataElements, ok := f.CodeShares[codeShareFn]; ok {
for k, v := range otherDataElements {
if _, ok := dataElements[k]; !ok {
Expand Down

0 comments on commit e56bf12

Please sign in to comment.