vrfs-774: updating musician_search logic
This commit is contained in:
parent
6f9f72c9b5
commit
fdf213ec66
|
|
@ -904,23 +904,28 @@ module JamRuby
|
|||
rel = User.where(:musician => true)
|
||||
unless (instrument = params[:instrument]).blank?
|
||||
rel = rel.joins("RIGHT JOIN musicians_instruments AS minst ON minst.user_id = users.id")
|
||||
.where(['minst.instrument_id = ?', instrument])
|
||||
.where(['minst.instrument_id = ? AND users.id IS NOT NULL', instrument])
|
||||
end
|
||||
|
||||
location_distance, location_city = params[:distance], params[:city]
|
||||
if location_distance && location_city
|
||||
citylatlng = [] # FIXME: get the lat/lng for the city
|
||||
rel = rel.within(location_distance, :origin => citylatlng)
|
||||
|
||||
if geo = MaxMindGeo.where(:city => params[:city]).limit(1).first
|
||||
citylatlng = [geo.lat, geo.lng]
|
||||
rel = rel.within(location_distance, :origin => citylatlng)
|
||||
end
|
||||
elsif current_user
|
||||
latlng = []
|
||||
if current_user.lat.nil?
|
||||
# FIXME: Lookup latlng from params[:remote_ip]
|
||||
if params[:remote_ip]
|
||||
if geo = MaxMindGeo.ip_lookup(params[:remote_ip])
|
||||
latlng = [geo.lat, geo.lng]
|
||||
end
|
||||
end
|
||||
else
|
||||
latlng = [current_user.lat, current_user.lng]
|
||||
end
|
||||
distance = location_distance || 50
|
||||
rel = rel.within(distance, :origin => latlng)
|
||||
rel = rel.within(distance, :origin => latlng) unless latlng.blank?
|
||||
end
|
||||
|
||||
case ordering = Search.order_param(params)
|
||||
|
|
|
|||
Loading…
Reference in New Issue