Remove detour over Enum.into(%{}) for keyword results to %Artikel{}

This commit is contained in:
Thelonius Kort
2023-03-01 16:01:14 +01:00
parent 6d0ae825d8
commit 3fe4a331ac

View File

@ -28,7 +28,7 @@ implement to_param protocol (no more needed for Outlook.Translations.Translation
where: t.public == true and t.language == ^language,
order_by: [desc: t.date]
Repo.all(q)
|> Enum.map(fn rec -> Enum.into(rec, %{}) end)
# |> Enum.map(fn rec -> Enum.into(rec, %{}) end)
|> Enum.map(fn map -> struct(Artikel, map) end)
end
@ -50,7 +50,7 @@ implement to_param protocol (no more needed for Outlook.Translations.Translation
where: t.id == ^id and t.public == true
case Repo.one(q) do
nil -> {:error, "Artikel does not exist, or isn't public."}
artikel -> {:ok, struct(Artikel, artikel |> Enum.into(%{}))}
artikel -> {:ok, struct(Artikel, artikel)}
end
end