mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-22 16:16:34 +00:00
User Search: Boost friends more strongly.
This commit is contained in:
parent
7e9f7ea0c2
commit
cb2bcee842
2 changed files with 23 additions and 2 deletions
|
@ -86,8 +86,8 @@ defmodule Pleroma.User.Search do
|
|||
search_rank:
|
||||
fragment(
|
||||
"""
|
||||
CASE WHEN (?) THEN (?) * 1.3
|
||||
WHEN (?) THEN (?) * 1.2
|
||||
CASE WHEN (?) THEN 0.5 + (?) * 1.3
|
||||
WHEN (?) THEN 0.5 + (?) * 1.2
|
||||
WHEN (?) THEN (?) * 1.1
|
||||
ELSE (?) END
|
||||
""",
|
||||
|
|
|
@ -366,4 +366,25 @@ defmodule Mix.Tasks.Pleroma.UserTest do
|
|||
refute user.info.confirmation_token
|
||||
end
|
||||
end
|
||||
|
||||
describe "search" do
|
||||
test "it returns users matching" do
|
||||
user = insert(:user)
|
||||
moon = insert(:user, nickname: "moon", name: "fediverse expert moon")
|
||||
moot = insert(:user, nickname: "moot")
|
||||
kawen = insert(:user, nickname: "kawen", name: "fediverse expert moon")
|
||||
|
||||
{:ok, user} = User.follow(user, kawen)
|
||||
|
||||
assert [moon.id, kawen.id] == User.Search.search("moon") |> Enum.map(& &1.id)
|
||||
res = User.search("moo") |> Enum.map(& &1.id)
|
||||
assert moon.id in res
|
||||
assert moot.id in res
|
||||
assert kawen.id in res
|
||||
assert [moon.id, kawen.id] == User.Search.search("moon fediverse") |> Enum.map(& &1.id)
|
||||
|
||||
assert [kawen.id, moon.id] ==
|
||||
User.Search.search("moon fediverse", for_user: user) |> Enum.map(& &1.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue