mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-04-02 01:35:27 +02:00
Add missing sorting to server-side autocomplete
This commit is contained in:
parent
2bc0fdfd33
commit
5eb4fb0b8a
1 changed files with 4 additions and 0 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue