models/eta.rb
def eta(dst)
    cars = Car.near_sphere(position: dst).where(available: true).limit(3)

    return nil if cars.count == 0

    etas = []
    cars.each do |car|
      etas << (cache_look(car.position, dst) || external(car.position, dst))
    end

    etas.reduce(&:+) / etas.length
  end
# 1. Look cache
# 2. Ask external service
1. Look cache
2. Ask external service
1 . Look cache 2 . Ask external service
def eta(dst)
    cars = Car.near_sphere(position: dst).where(available: true).limit(3)
    return nil if cars.count == 0
    etas = []
    cars.each do |car|
      etas << (cache_look(car.position, dst) || external(car.position, dst))
    end
    etas.reduce(&:+) / etas.length
  end
def eta ( dst ) cars = Car . near_sphere ( position : dst ) . where ( available : true ) . limit ( 3 ) return nil if cars . count == 0 etas = [ ] cars . each do | car | etas << ( cache_look ( car . position , dst ) || external ( car . position , dst ) ) end etas . reduce ( & :+ ) / etas . length end
1.
1 .
dst