From e8089eb24ee3d3c0259467f5080f2adf6b2c5dad Mon Sep 17 00:00:00 2001 From: Thelonius Kort Date: Wed, 1 Mar 2023 12:41:09 +0100 Subject: [PATCH] Add important amendment Yesterday night it got late... --- lib/outlook/artikel.ex | 47 ------------------------------------------ lib/outlook/public.ex | 2 +- 2 files changed, 1 insertion(+), 48 deletions(-) delete mode 100644 lib/outlook/artikel.ex diff --git a/lib/outlook/artikel.ex b/lib/outlook/artikel.ex deleted file mode 100644 index 2d369ce..0000000 --- a/lib/outlook/artikel.ex +++ /dev/null @@ -1,47 +0,0 @@ -defmodule Outlook.Artikel do - @moduledoc """ - The Artikel context. - """ - - alias Outlook.Translations.Translation - alias Outlook.Articles.Article - alias Outlook.Authors.Author - - import Ecto.Query, warn: false - alias Outlook.Repo - - def list_artikel do - Repo.all(from t in Translation, where: t.public == true) - |> Repo.preload([article: :author]) - end - - def get_artikel!(artikel) when is_struct(artikel), do: get_artikel!(artikel.id) - def get_artikel!(id) do - q = from t in Translation, - join: a in Article, on: t.article_id == a.id, - join: au in Author, on: a.author_id == au.id, - select: [ - title: t.title, - date: t.date, - public_content: t.public_content, - title_org: a.title, - url_org: a.url, - date_org: a.date, - author: au.name, - author_id: au.id - ], - 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, artikel |> Enum.into(%{})} - end - end - - def get_artikel_by_tid(tid) do - artikel = tid - |> String.split(~r/--(?=[0-9A-Za-z])/) - |> List.last() - |> String.to_integer(36) - |> get_artikel!() - end -end diff --git a/lib/outlook/public.ex b/lib/outlook/public.ex index 73675b0..b7fc0a8 100644 --- a/lib/outlook/public.ex +++ b/lib/outlook/public.ex @@ -44,7 +44,7 @@ implement to_param protocol (no more needed for Outlook.Translations.Translation title_org: a.title, url_org: a.url, date_org: a.date, - author: au.name, + autor_name: au.name, author_id: au.id ], where: t.id == ^id and t.public == true