func (c *CheapestFlightCache) Update(flight *model.Flight) UpdateResult { id := *flight.Id() newFare := flight.CheapestAvailableFare() oldFlight, existed := c.cache[id] if !existed { if newFare == nil { return Unchanged } else { c.cache[id] = flight return Added } } if newFare == nil { delete(c.cache, id) return Removed } else if newFare.Cents < oldFlight.CheapestAvailableFare().Cents { c.cache[id] = flight return Added } else { return Unchanged } }
func (m *MaxAvailableFareFilter) Matches(flight *model.Flight) bool { return flight.CheapestAvailableFare().Cents <= m.Cents }
func (m *MaxAvailableFareFilter) Matches(flight *model.Flight) bool { cheapestAvailableFare := flight.CheapestAvailableFare() return cheapestAvailableFare != nil && flight.CheapestAvailableFare().Cents <= m.Cents }