propagate aliases to non-image tag list entries

This commit is contained in:
byte[] 2020-09-27 23:03:53 -04:00
parent 76a1cf8b3a
commit c7cd7f3af3

View file

@ -32,12 +32,13 @@ defmodule Philomena.Schema.TagList do
Tag Tag
|> where([t], t.name in ^tag_list) |> where([t], t.name in ^tag_list)
|> Repo.all() |> 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_ids =
tag_list tag_list
|> Enum.map(&lookup[&1]) |> Enum.map(&lookup[&1])
|> Enum.reject(&is_nil/1) |> Enum.reject(&is_nil/1)
|> Enum.uniq()
changeset changeset
|> put_change(target_field, tag_ids) |> put_change(target_field, tag_ids)