Move user search to User module.
This commit is contained in:
parent
efe12e1a73
commit
502cb38cd6
4 changed files with 27 additions and 15 deletions
|
|
@ -274,4 +274,14 @@ defmodule Pleroma.User do
|
|||
|
||||
Repo.all(query)
|
||||
end
|
||||
|
||||
def search(query, resolve) do
|
||||
if resolve do
|
||||
User.get_or_fetch_by_nickname(query)
|
||||
end
|
||||
q = from u in User,
|
||||
where: fragment("(to_tsvector('english', ?) || to_tsvector('english', ?)) @@ plainto_tsquery('english', ?)", u.nickname, u.name, ^query),
|
||||
limit: 20
|
||||
Repo.all(q)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue