Extend search tweak patches
This commit is contained in:
parent
ed201717b4
commit
84cfeed4d9
1 changed files with 57 additions and 0 deletions
|
|
@ -3653,3 +3653,60 @@ index 000000000..9315f1b7d
|
|||
+end
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
||||
From 9b94b30346c2566cd6b84a2f9e28bc48ca23005b Mon Sep 17 00:00:00 2001
|
||||
From: Oneric <oneric@oneric.stub>
|
||||
Date: Wed, 29 Apr 2026 00:00:00 +0000
|
||||
Subject: [PATCH] user/search: break tie on equal search rank
|
||||
|
||||
By preferring local accounts and then accounts
|
||||
the server knows about for longer.
|
||||
|
||||
I considered using last_status_at to prefer accounts
|
||||
with more recent publicly visible activity, but this
|
||||
might make pagination iffy when new statuses are posted
|
||||
in between API calls.
|
||||
---
|
||||
lib/pleroma/user/search.ex | 4 ++--
|
||||
test/mix/tasks/pleroma/user_test.exs | 2 +-
|
||||
2 files changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/pleroma/user/search.ex b/lib/pleroma/user/search.ex
|
||||
index 61b9ef41b3..72621a9b4c 100644
|
||||
--- a/lib/pleroma/user/search.ex
|
||||
+++ b/lib/pleroma/user/search.ex
|
||||
@@ -188,7 +188,7 @@ defp nick_prefix_matches(nick_prefix, for_user, local_only, following, result_li
|
||||
|> selected_as(:search_rank)
|
||||
}
|
||||
)
|
||||
- |> order_by(desc: selected_as(:search_rank))
|
||||
+ |> order_by([u], desc: selected_as(:search_rank), desc: u.local, asc: u.id)
|
||||
|> Pagination.fetch_paginated(%{"offset" => offset, "limit" => result_limit}, :offset)
|
||||
end
|
||||
|
||||
@@ -220,7 +220,7 @@ defp do_fts_search(query_string, for_user, local_only, following, offset, result
|
||||
|> filter_user_query(for_user, local_only)
|
||||
|> fts_search(query_string)
|
||||
|> trigram_rank(query_string)
|
||||
- |> order_by(desc: selected_as(:search_rank))
|
||||
+ |> order_by([u], desc: selected_as(:search_rank), desc: u.local, asc: u.id)
|
||||
|> Pagination.fetch_paginated(%{"offset" => offset, "limit" => result_limit}, :offset)
|
||||
end
|
||||
|
||||
diff --git a/test/mix/tasks/pleroma/user_test.exs b/test/mix/tasks/pleroma/user_test.exs
|
||||
index 469de37c3e..011be404d9 100644
|
||||
--- a/test/mix/tasks/pleroma/user_test.exs
|
||||
+++ b/test/mix/tasks/pleroma/user_test.exs
|
||||
@@ -511,7 +511,7 @@ test "it returns users matching" do
|
||||
res = User.Search.search("moo") |> Enum.map(& &1.id)
|
||||
assert Enum.sort([moon.id, moot.id]) == Enum.sort(res)
|
||||
|
||||
- assert [kawen.id, moon.id] == User.Search.search("expert fediverse") |> Enum.map(& &1.id)
|
||||
+ assert [moon.id, kawen.id] == User.Search.search("expert fediverse") |> Enum.map(& &1.id)
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue