Commit 131494f2 authored by syasonik's avatar syasonik

Refactor metrics_dashboard response conditionals

parent c1c0fb66
......@@ -159,12 +159,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def metrics_dashboard
render_403 && return unless Feature.enabled?(:environment_metrics_use_prometheus_endpoint, @project)
respond_to do |format|
format.json do
result = Gitlab::MetricsDashboard::Service.new(@project, @current_user, environment: environment).get_dashboard
render_metrics_dashboard_response(result)
respond_to do |format|
if result[:status] == :success
format.json { render status: :ok, json: result }
else
format.json { render status: result[:http_status], json: result }
end
end
end
......@@ -209,13 +210,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
params.require([:start, :end])
end
def render_metrics_dashboard_response(result)
ok_status = :ok if result[:status] == :success
status = ok_status || result[:http_status] || :bad_request
render status: status, json: result
end
def search_environment_names
return [] unless params[:query]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment