mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
exclude unused and once-off tags from automatic completion
This commit is contained in:
parent
75be0794c0
commit
c1992d272b
1 changed files with 3 additions and 1 deletions
|
@ -25,12 +25,14 @@ defmodule PhilomenaWeb.Tag.AutocompleteController do
|
|||
},
|
||||
sort: %{images: :desc}
|
||||
},
|
||||
%{page_size: 5}
|
||||
%{page_size: 10}
|
||||
)
|
||||
|> Elasticsearch.search_records(preload(Tag, :aliased_tag))
|
||||
|> Enum.map(&(&1.aliased_tag || &1))
|
||||
|> Enum.uniq_by(& &1.id)
|
||||
|> Enum.filter(& &1.images_count > 3)
|
||||
|> Enum.sort_by(&(-&1.images_count))
|
||||
|> Enum.take(5)
|
||||
|> Enum.map(&%{label: "#{&1.name} (#{&1.images_count})", value: &1.name})
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue