From c1992d272b50fc05ab6427a9f079d1bb2ae82776 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 13 Dec 2020 11:10:36 -0500 Subject: [PATCH] exclude unused and once-off tags from automatic completion --- lib/philomena_web/controllers/tag/autocomplete_controller.ex | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/philomena_web/controllers/tag/autocomplete_controller.ex b/lib/philomena_web/controllers/tag/autocomplete_controller.ex index 66433852..0256c2cc 100644 --- a/lib/philomena_web/controllers/tag/autocomplete_controller.ex +++ b/lib/philomena_web/controllers/tag/autocomplete_controller.ex @@ -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