mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-21 15:13:52 +01:00
Order by if they have profile info
This commit is contained in:
parent
a757dd4863
commit
036362ede6
1 changed files with 11 additions and 2 deletions
|
@ -274,14 +274,20 @@ class UserDirectoryStore(SQLBaseStore):
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
search_query = _parse_query(self.database_engine, search_term)
|
search_query = _parse_query(self.database_engine, search_term)
|
||||||
|
|
||||||
if isinstance(self.database_engine, PostgresEngine):
|
if isinstance(self.database_engine, PostgresEngine):
|
||||||
|
# We order by rank and then if they have profile info
|
||||||
sql = """
|
sql = """
|
||||||
SELECT user_id, display_name, avatar_url
|
SELECT user_id, display_name, avatar_url
|
||||||
FROM user_directory_search
|
FROM user_directory_search
|
||||||
INNER JOIN user_directory USING (user_id)
|
INNER JOIN user_directory USING (user_id)
|
||||||
WHERE vector @@ to_tsquery('english', ?)
|
WHERE vector @@ to_tsquery('english', ?)
|
||||||
ORDER BY ts_rank_cd(vector, to_tsquery('english', ?)) DESC
|
ORDER BY
|
||||||
|
ts_rank_cd(vector, to_tsquery('english', ?)) DESC,
|
||||||
|
display_name IS NULL,
|
||||||
|
avatar_url IS NULL
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
"""
|
"""
|
||||||
args = (search_query, search_query, limit + 1,)
|
args = (search_query, search_query, limit + 1,)
|
||||||
|
@ -291,7 +297,10 @@ class UserDirectoryStore(SQLBaseStore):
|
||||||
FROM user_directory_search
|
FROM user_directory_search
|
||||||
INNER JOIN user_directory USING (user_id)
|
INNER JOIN user_directory USING (user_id)
|
||||||
WHERE value MATCH ?
|
WHERE value MATCH ?
|
||||||
ORDER BY rank(matchinfo(user_directory)) DESC
|
ORDER BY
|
||||||
|
rank(matchinfo(user_directory)) DESC,
|
||||||
|
display_name IS NULL,
|
||||||
|
avatar_url IS NULL
|
||||||
LIMIT ?
|
LIMIT ?
|
||||||
"""
|
"""
|
||||||
args = (search_query, limit + 1)
|
args = (search_query, limit + 1)
|
||||||
|
|
Loading…
Reference in a new issue