Plots2: واجهة برمجة تطبيقات البحث: نقطة النهاية / srch / قريب يحتاج الأشخاص إلى الفرز حسب أحدث المستخدمين

تم إنشاؤها على ٢٢ أكتوبر ٢٠١٨  ·  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 التقييمات