Add missing sorting to server-side autocomplete

This commit is contained in:
MareStare 2025-03-27 01:24:24 +00:00
parent 2bc0fdfd33
commit 5eb4fb0b8a

View file

@ -81,6 +81,10 @@ defmodule PhilomenaWeb.Autocomplete.TagController do
}
)
|> Enum.filter(&(&1.images > 0))
# Sometimes we have data desynchronization between OpenSearch and Postgres due
# to bugs. This client-side sort serves as a patch to make sure we have correct
# ranking of the autocomplete results even in the case of desynchronization.
|> Enum.sort_by(& &1.images, :desc)
|> Enum.take(limit)
end