mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
fixes #104: show aliases in autocomplete
This commit is contained in:
parent
406c7dd74b
commit
0b8cad77dd
1 changed files with 4 additions and 1 deletions
|
@ -3,6 +3,7 @@ defmodule PhilomenaWeb.Tag.AutocompleteController do
|
|||
|
||||
alias Philomena.Elasticsearch
|
||||
alias Philomena.Tags.Tag
|
||||
import Ecto.Query
|
||||
|
||||
def show(conn, params) do
|
||||
tags =
|
||||
|
@ -25,8 +26,10 @@ defmodule PhilomenaWeb.Tag.AutocompleteController do
|
|||
sort: %{images: :desc}
|
||||
},
|
||||
%{page_size: 5},
|
||||
Tag
|
||||
Tag |> preload(:aliased_tag)
|
||||
)
|
||||
|> Enum.map(&(&1.aliased_tag || &1))
|
||||
|> Enum.sort_by(&(-&1.images_count))
|
||||
|> Enum.map(&%{label: "#{&1.name} (#{&1.images_count})", value: &1.name})
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue