Plots2: ๊ฒ€์ƒ‰ API: ๋์  /srch/nearbyPeople์€ ๊ฐ€์žฅ ์ตœ๊ทผ ์‚ฌ์šฉ์ž๋ณ„๋กœ ์ •๋ ฌํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์— ๋งŒ๋“  2018๋…„ 10์›” 22์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: publiclab/plots2

์—ฌ๊ธฐ์—์„œ ๋…ผ์˜ํ•œ ๋ฐ”์™€ ๊ฐ™์ด( ์งˆ๋ฌธ: ์ง€๋„์— ๋” ๋งŽ์€ ๋ฐ์ดํ„ฐ ๋ ˆ์ด์–ด๋ฅผ ํ‘œ์‹œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ? ) ์ฃผ์–ด์ง„ ์œ„๋„, ๊ฒฝ๋„ ๋ฐ ํƒœ๊ทธ(์„ ํƒ ์‚ฌํ•ญ)์™€ ๊ด€๋ จํ•˜์—ฌ ์ฃผ๋ณ€ ์‚ฌ๋žŒ๋“ค์„ ๊ฒ€์ƒ‰ํ•˜๋Š” ์ƒˆ๋กœ์šด ๋ฐฉ๋ฒ•์„ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค(#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() ๋ฐฉ๋ฒ•์€ ๊ฐ€์žฅ ์ตœ๊ทผ ์‚ฌ์šฉ์ž๋กœ ๊ฒฐ๊ณผ๋ฅผ ์ •๋ ฌํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—์„œ๋„ ๋™์ผํ•œ ์ „๋žต์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ฉ๋‹ˆ๋‹ค.

Ruby help wanted search

๋ชจ๋“  3 ๋Œ“๊ธ€

์—„์ฒญ๋‚œ !!!

@milaaraujo ์ด ์ž‘์—…์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

๋ฌผ๋ก , ๋ฌธ์ œ๋ฅผ ์ž์‹ ์—๊ฒŒ ํ• ๋‹นํ•˜์‹ญ์‹œ์˜ค!

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰