From 53ad9dd13916c8618c281ca5b61472d0149dd072 Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 10 May 2020 06:41:57 -0400 Subject: [PATCH] unique tags in autocomplete --- lib/philomena_web/controllers/tag/autocomplete_controller.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/philomena_web/controllers/tag/autocomplete_controller.ex b/lib/philomena_web/controllers/tag/autocomplete_controller.ex index 7db0ee64..ca16f3f5 100644 --- a/lib/philomena_web/controllers/tag/autocomplete_controller.ex +++ b/lib/philomena_web/controllers/tag/autocomplete_controller.ex @@ -29,6 +29,7 @@ defmodule PhilomenaWeb.Tag.AutocompleteController do Tag |> preload(:aliased_tag) ) |> Enum.map(&(&1.aliased_tag || &1)) + |> Enum.uniq_by(&(&1.id)) |> Enum.sort_by(&(-&1.images_count)) |> Enum.map(&%{label: "#{&1.name} (#{&1.images_count})", value: &1.name}) end