Skip to content

Commit

Permalink
try different location for eager loading
Browse files Browse the repository at this point in the history
Ref #7556
  • Loading branch information
daemon1024 committed Jul 16, 2021
1 parent 52e4708 commit f3c213f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions app/services/search_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,8 @@ def tagNearbyPeople(coordinates, tag, field, period = nil, sort_by = nil, order_
raise("If 'from' is not null, must contain date") if period["from"] && !(period["from"].is_a? Date)
raise("If 'to' is not null, must contain date") if period["to"] && !(period["to"].is_a? Date)

user_locations = User.where('rusers.status <> 0')
user_locations = User.includes(:user_tag)
.where('rusers.status <> 0')
.joins(:user_tags)
.where('user_tags.value LIKE ?', 'lat%')
.where('REPLACE(user_tags.value, "lat:", "") BETWEEN ' + coordinates["selat"].to_s + ' AND ' + coordinates["nwlat"].to_s)
Expand All @@ -194,7 +195,7 @@ def tagNearbyPeople(coordinates, tag, field, period = nil, sort_by = nil, order_
.limit(limit)
.collect(&:id).uniq || []
end
user_locations = user_locations.includes(:user_tag).where('rusers.id IN (?)', uids).distinct
user_locations = user_locations.where('rusers.id IN (?)', uids).distinct
end

items = user_locations
Expand Down

0 comments on commit f3c213f

Please sign in to comment.