Join on contacts correctly in search
This commit is contained in:
parent
4deec0cb38
commit
661d5e41a1
1 changed files with 9 additions and 2 deletions
|
|
@ -55,8 +55,15 @@ class Person < ActiveRecord::Base
|
|||
sql << where_clause
|
||||
tokens.concat([token, token, token])
|
||||
end
|
||||
|
||||
Person.searchable.where(sql, *tokens).includes(:contacts).order("contacts.user_id DESC", "profiles.last_name ASC", "profiles.first_name ASC", "people.diaspora_handle ASC")
|
||||
#SELECT `people`.* FROM people
|
||||
# INNER JOIN `profiles` ON `profiles`.person_id = `people`.id
|
||||
# LEFT OUTER JOIN `contacts` ON (`contacts`.user_id = #{user.id} AND `contacts`.person_id = `people`.id)
|
||||
# WHERE `profiles`.searchable = true AND
|
||||
# `profiles`.first_name LIKE '%Max%'
|
||||
# ORDER BY `contacts`.user_id DESC
|
||||
Person.searchable.where(sql, *tokens).joins(
|
||||
"LEFT OUTER JOIN `contacts` ON `contacts`.user_id = #{user.id} AND `contacts`.person_id = `people`.id"
|
||||
).order("contacts.user_id DESC", "profiles.last_name ASC", "profiles.first_name ASC", "people.diaspora_handle ASC")
|
||||
end
|
||||
|
||||
def name
|
||||
|
|
|
|||
Loading…
Reference in a new issue