Make search result order match the order of objects received from Meilisearch #579
1 changed files with 7 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue