~ihabunek/triglav

29b644d12592960d904aaccf51090cfbbd8ed1c0 — Ivan Habunek 9 months ago c68c901
Clean up feed urls and iris
1 files changed, 8 insertions(+), 11 deletions(-)

M lib/triglav_web/controllers/zet/errors_controller.ex
M lib/triglav_web/controllers/zet/errors_controller.ex => lib/triglav_web/controllers/zet/errors_controller.ex +8 -11
@@ 11,7 11,8 @@ defmodule TriglavWeb.Zet.ErrorsController do

  def atom(conn, _params) do
    history = Errors.list_history()
    root_url = TriglavWeb.Router.Helpers.url(conn)
    self_url = TriglavWeb.Router.Helpers.zet_errors_url(conn, :atom)
    base_url = TriglavWeb.Router.Helpers.zet_errors_url(conn, :index)

    last_updated =
      if length(history) > 0,


@@ 19,14 20,10 @@ defmodule TriglavWeb.Zet.ErrorsController do
        else: ~U"2000-01-01T00:00:00Z"

    feed =
      Feed.new(
        "#{root_url}/zet/errors/history",
        last_updated,
        "ZET error history"
      )
      |> Feed.link("#{root_url}/errors/history/atom", rel: "self")
      |> Feed.entries(Enum.map(history, &to_entry(&1, root_url)))
      |> Feed.build()
      Feed.new(base_url, last_updated, "ZET error history")
      |> Feed.link(self_url, rel: "self")
      |> Feed.link(base_url, rel: "alternate", type: "text/html")
      |> Feed.entries(Enum.map(history, &to_entry(&1, base_url)))
      |> Atomex.generate_document()

    conn


@@ 34,7 31,7 @@ defmodule TriglavWeb.Zet.ErrorsController do
    |> send_resp(conn.status || 200, feed)
  end

  defp to_entry(history_item, root_url) do
  defp to_entry(history_item, base_url) do
    counts = %{
      current: history_item.count,
      previous: history_item.previous_count,


@@ 43,7 40,7 @@ defmodule TriglavWeb.Zet.ErrorsController do
      diff: history_item.created_count - history_item.resolved_count
    }

    id = "#{root_url}/zet/errors/history/#{history_item.id}"
    id = "#{base_url}/#{history_item.id}"
    title = "Errors count changed #{counts.current} (+#{counts.created} -#{counts.resolved})"

    content = """