Skip to content

Commit

Permalink
exclude unused and once-off tags from automatic completion
Browse files Browse the repository at this point in the history
  • Loading branch information
liamwhite committed Dec 13, 2020
1 parent 75be079 commit c1992d2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/philomena_web/controllers/tag/autocomplete_controller.ex
Expand Up @@ -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

Expand Down

0 comments on commit c1992d2

Please sign in to comment.