From c7cd7f3af3990d41d461511f0dddb59b1b1832fe Mon Sep 17 00:00:00 2001 From: "byte[]" Date: Sun, 27 Sep 2020 23:03:53 -0400 Subject: [PATCH] propagate aliases to non-image tag list entries --- lib/philomena/schema/tag_list.ex | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/philomena/schema/tag_list.ex b/lib/philomena/schema/tag_list.ex index fdead530..9b1db6c3 100644 --- a/lib/philomena/schema/tag_list.ex +++ b/lib/philomena/schema/tag_list.ex @@ -32,12 +32,13 @@ defmodule Philomena.Schema.TagList do Tag |> where([t], t.name in ^tag_list) |> Repo.all() - |> Map.new(fn t -> {t.name, t.id} end) + |> Map.new(fn t -> {t.name, t.aliased_tag_id || t.id} end) tag_ids = tag_list |> Enum.map(&lookup[&1]) |> Enum.reject(&is_nil/1) + |> Enum.uniq() changeset |> put_change(target_field, tag_ids)