mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-02-01 03:46:44 +01:00
handle aliases in tag input
This commit is contained in:
parent
b36ef1dd23
commit
413c19a97d
1 changed files with 6 additions and 2 deletions
|
@ -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 ->
|
||||
|
|
Loading…
Reference in a new issue