Skip to content

Commit

Permalink
ActiveRecord::Base.connection.adapter_name == 'Mysql2'
Browse files Browse the repository at this point in the history
  • Loading branch information
milaaraujo committed Aug 11, 2018
1 parent 9aa3ef5 commit e4a72e5
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/services/srch_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,23 @@ def self.find_questions(input, limit, order)
end

def self.find_locations(limit, user_tag = nil)
user_locations = User.where('rusers.status <> 0')\
.joins(:user_tags)\
.where('value LIKE "lat:%"')\
.joins(:revisions)\
.order("node_revisions.timestamp DESC")\
.distinct
user_locations =
if ActiveRecord::Base.connection.adapter_name == 'Mysql2'
User.select('rusers.*,node_revisions.timestamp')
.where('rusers.status <> 0')\
.joins(:user_tags)\
.where('value LIKE "lat:%"')\
.joins(:revisions)\
.order("node_revisions.timestamp DESC")\
.distinct
else
User.where('rusers.status <> 0')\
.joins(:user_tags)\
.where('value LIKE "lat:%"')\
.joins(:revisions)\
.order("node_revisions.timestamp DESC")\
.distinct
end
if user_tag.present?
user_locations = User.joins(:user_tags)\
.where('user_tags.value LIKE ?', user_tag)\
Expand Down

0 comments on commit e4a72e5

Please sign in to comment.