From 75cec534920b029a8e7385776401f06cc6afcd6c Mon Sep 17 00:00:00 2001 From: EMaksy Date: Tue, 1 Oct 2024 11:10:09 +0200 Subject: [PATCH] Address coments --- lib/wanda_web/controllers/fallback_controller.ex | 6 +++--- lib/wanda_web/controllers/health_controller.ex | 2 +- lib/wanda_web/views/v1/execution_json.ex | 3 +-- lib/wanda_web/views/v2/catalog_json.ex | 2 +- lib/wanda_web/views/v2/execution_json.ex | 4 +--- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/wanda_web/controllers/fallback_controller.ex b/lib/wanda_web/controllers/fallback_controller.ex index 39b4abd0..edaf3fc9 100644 --- a/lib/wanda_web/controllers/fallback_controller.ex +++ b/lib/wanda_web/controllers/fallback_controller.ex @@ -6,21 +6,21 @@ defmodule WandaWeb.FallbackController do def call(conn, {:error, :no_checks_selected}) do conn |> put_status(:unprocessable_entity) - |> put_view(ErrorJSON) + |> put_view(json: ErrorJSON) |> render(:"422", reason: "No checks were selected.") end def call(conn, {:error, :already_running}) do conn |> put_status(:unprocessable_entity) - |> put_view(ErrorJSON) + |> put_view(json: ErrorJSON) |> render(:"422", reason: "Execution already running.") end def call(conn, _) do conn |> put_status(:internal_server_error) - |> put_view(ErrorJSON) + |> put_view(json: ErrorJSON) |> render(:"500") end end diff --git a/lib/wanda_web/controllers/health_controller.ex b/lib/wanda_web/controllers/health_controller.ex index d2a2b02f..59b330de 100644 --- a/lib/wanda_web/controllers/health_controller.ex +++ b/lib/wanda_web/controllers/health_controller.ex @@ -42,6 +42,6 @@ defmodule WandaWeb.HealthController do conn |> put_status(if db_status == :pass, do: 200, else: 500) - |> render("health.json", health: %{database: db_status}) + |> render(:health, health: %{database: db_status}) end end diff --git a/lib/wanda_web/views/v1/execution_json.ex b/lib/wanda_web/views/v1/execution_json.ex index 9bb37f51..76a5faa5 100644 --- a/lib/wanda_web/views/v1/execution_json.ex +++ b/lib/wanda_web/views/v1/execution_json.ex @@ -1,6 +1,5 @@ defmodule WandaWeb.V1.ExecutionJSON do alias Wanda.Executions.Execution - alias WandaWeb.V1.ExecutionJSON def index(%{executions: executions, total_count: total_count}) do %{ @@ -16,7 +15,7 @@ defmodule WandaWeb.V1.ExecutionJSON do end def show(%{execution: execution}) do - ExecutionJSON.execution(execution) + execution(execution) end def start(%{ diff --git a/lib/wanda_web/views/v2/catalog_json.ex b/lib/wanda_web/views/v2/catalog_json.ex index 9b80f654..7cf87f7d 100644 --- a/lib/wanda_web/views/v2/catalog_json.ex +++ b/lib/wanda_web/views/v2/catalog_json.ex @@ -2,6 +2,6 @@ defmodule WandaWeb.V2.CatalogJSON do alias WandaWeb.V1.CatalogJSON def catalog(%{catalog: catalog}) do - %{items: Enum.map(catalog, fn check -> CatalogJSON.check(check) end)} + %{items: Enum.map(catalog, &CatalogJSON.check/1)} end end diff --git a/lib/wanda_web/views/v2/execution_json.ex b/lib/wanda_web/views/v2/execution_json.ex index 0076e2ad..9801d38c 100644 --- a/lib/wanda_web/views/v2/execution_json.ex +++ b/lib/wanda_web/views/v2/execution_json.ex @@ -1,6 +1,4 @@ defmodule WandaWeb.V2.ExecutionJSON do - alias WandaWeb.V2.ExecutionJSON - alias Wanda.Executions.Execution def index(%{executions: executions, total_count: total_count}) do @@ -11,7 +9,7 @@ defmodule WandaWeb.V2.ExecutionJSON do end def show(%{execution: execution}) do - ExecutionJSON.execution(execution) + execution(execution) end def execution(%Execution{