Make search result order match the order of objects received from Meilisearch #579

Open
AdamK2003 wants to merge 1 commit from AdamK2003/akkoma:meilisearch-result-order into develop
Showing only changes of commit 7dd439807f - Show all commits

View file

@ -90,7 +90,7 @@ def search(user, query, options \\ []) do
hits = result["hits"] |> Enum.map(& &1["ap"]) hits = result["hits"] |> Enum.map(& &1["ap"])
try do try do
hits fetched = hits
|> Activity.create_by_object_ap_id() |> Activity.create_by_object_ap_id()
|> Activity.with_preloaded_object() |> Activity.with_preloaded_object()
|> Activity.with_preloaded_object() |> Activity.with_preloaded_object()
@ -99,8 +99,13 @@ def search(user, query, options \\ []) do
|> maybe_restrict_author(author) |> maybe_restrict_author(author)
|> maybe_restrict_blocked(user) |> maybe_restrict_blocked(user)
|> maybe_fetch(user, query) |> maybe_fetch(user, query)
|> order_by([object: obj], desc: obj.data["published"]) # |> order_by([object: obj], desc: obj.data["published"])
|> Pleroma.Repo.all() |> Pleroma.Repo.all()
for hit <- hits do
Enum.find(fetched, fn object -> object.data["object"] == hit end)
end
rescue rescue
_ -> maybe_fetch([], user, query) _ -> maybe_fetch([], user, query)
end end