handle aliases in tag input

This commit is contained in:
byte[] 2019-12-04 16:42:13 -05:00
parent b36ef1dd23
commit 413c19a97d

View file

@ -17,8 +17,7 @@ defmodule Philomena.Tags do
|> where([t], t.name in ^tag_names)
|> preload([:implied_tags, aliased_tag: :implied_tags])
|> Repo.all()
|> Enum.map(& &1.aliased_tag || &1)
|> Enum.uniq()
|> Enum.uniq_by(& &1.name)
existent_tag_names =
existent_tags
@ -28,6 +27,11 @@ defmodule Philomena.Tags do
tag_names
|> Enum.reject(&existent_tag_names[&1])
# Now get rid of the aliases
existent_tags =
existent_tags
|> Enum.map(& &1.aliased_tag || &1)
new_tags =
nonexistent_tag_names
|> Enum.map(fn name ->