์ฌ๊ธฐ์์ ๋ ผ์ํ ๋ฐ์ ๊ฐ์ด( ์ง๋ฌธ: ์ง๋์ ๋ ๋ง์ ๋ฐ์ดํฐ ๋ ์ด์ด๋ฅผ ํ์ํ ์ ์์ต๋๊น? ) ์ฃผ์ด์ง ์๋, ๊ฒฝ๋ ๋ฐ ํ๊ทธ(์ ํ ์ฌํญ)์ ๊ด๋ จํ์ฌ ์ฃผ๋ณ ์ฌ๋๋ค์ ๊ฒ์ํ๋ ์๋ก์ด ๋ฐฉ๋ฒ์ ๊ตฌํํ์ต๋๋ค(#3719).
์ฝ๋๋ ์ฌ๊ธฐ์ ์์ต๋๋ค: https://github.com/publiclab/plots2/blob/master/app/services/search_service.rb#L118 -L146
def tagNearbyPeople(query, tag, limit = 10)
raise("Must separate coordinates with ,") unless query.include? ","
lat, lon = query.split(',')
user_locations = User.where('rusers.status <> 0')\
.joins(:user_tags)\
.where('value LIKE ?', 'lat:' + lat[0..lat.length - 2] + '%')\
.distinct
if tag.present?
user_locations = User.joins(:user_tags)\
.where('user_tags.value LIKE ?', tag)\
.where(id: user_locations.select("rusers.id"))
end
ids = user_locations.collect(&:id).uniq || []
items = User.where('rusers.status <> 0').joins(:user_tags)
.where('rusers.id IN (?) AND value LIKE ?', ids, 'lon:' + lon[0..lon.length - 2] + '%')
# selects the items whose node_tags don't have the location:blurred tag
items.select do |item|
item.user_tags.none? do |user_tag|
user_tag.name == "location:blurred"
end
end
items = items.limit(limit)
end
์ด์ ๋ค์ ๋จ๊ณ๋ก ์ต์ํ ๊ฐ์ฅ ์ต๊ทผ์ ๊ฐ์ ํ ์์๋๋ก ๊ฒฐ๊ณผ๋ฅผ ์ ๋ ฌํ๋๋ก ๋ฉ์๋๋ฅผ ์์ ํด์ผ ํฉ๋๋ค.
search_profiles()
๋ฐฉ๋ฒ์ ๊ฐ์ฅ ์ต๊ทผ ์ฌ์ฉ์๋ก ๊ฒฐ๊ณผ๋ฅผ ์ ๋ ฌํฉ๋๋ค. ์ฌ๊ธฐ์์๋ ๋์ผํ ์ ๋ต์ ์ฌ์ฉํ ์ ์๋ค๊ณ ์๊ฐํฉ๋๋ค.
์์ฒญ๋ !!!
@milaaraujo ์ด ์์ ์ ํ ์ ์์ต๋๊น?
๋ฌผ๋ก , ๋ฌธ์ ๋ฅผ ์์ ์๊ฒ ํ ๋นํ์ญ์์ค!