Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
EMaksy committed Oct 1, 2024
1 parent bd4d48d commit b1d4569
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lib/wanda_web/controllers/fallback_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/wanda_web/controllers/health_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions lib/wanda_web/views/v1/execution_json.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule WandaWeb.V1.ExecutionJSON do
alias Wanda.Executions.Execution
alias WandaWeb.V1.ExecutionJSON
alias WandaWeb.V2

def index(%{executions: executions, total_count: total_count}) do
%{
Expand All @@ -9,14 +9,8 @@ defmodule WandaWeb.V1.ExecutionJSON do
}
end

def execution(%Execution{} = execution) do
execution
|> WandaWeb.V2.ExecutionJSON.execution()
|> adapt_v1()
end

def show(%{execution: execution}) do
ExecutionJSON.execution(execution)
execution(execution)
end

def start(%{
Expand Down Expand Up @@ -69,6 +63,12 @@ defmodule WandaWeb.V1.ExecutionJSON do

defp adapt_v1_agent_check_results(agent_check_results), do: agent_check_results

defp execution(%Execution{} = execution) do
execution
|> V2.ExecutionJSON.execution()
|> adapt_v1()
end

defp update_expect_enum(expectations) do
Enum.map(expectations, fn
%{"type" => "expect_enum"} = expectation -> Map.put(expectation, "type", "unknown")
Expand Down
2 changes: 1 addition & 1 deletion lib/wanda_web/views/v2/catalog_json.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 1 addition & 3 deletions lib/wanda_web/views/v2/execution_json.ex
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -11,7 +9,7 @@ defmodule WandaWeb.V2.ExecutionJSON do
end

def show(%{execution: execution}) do
ExecutionJSON.execution(execution)
execution(execution)
end

def execution(%Execution{
Expand Down

0 comments on commit b1d4569

Please sign in to comment.