Commit 131494f2 authored by syasonik's avatar syasonik

Refactor metrics_dashboard response conditionals

parent c1c0fb66
...@@ -159,12 +159,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -159,12 +159,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def metrics_dashboard def metrics_dashboard
render_403 && return unless Feature.enabled?(:environment_metrics_use_prometheus_endpoint, @project) render_403 && return unless Feature.enabled?(:environment_metrics_use_prometheus_endpoint, @project)
result = Gitlab::MetricsDashboard::Service.new(@project, @current_user, environment: environment).get_dashboard
respond_to do |format| respond_to do |format|
format.json do if result[:status] == :success
result = Gitlab::MetricsDashboard::Service.new(@project, @current_user, environment: environment).get_dashboard format.json { render status: :ok, json: result }
else
render_metrics_dashboard_response(result) format.json { render status: result[:http_status], json: result }
end end
end end
end end
...@@ -209,13 +210,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -209,13 +210,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
params.require([:start, :end]) params.require([:start, :end])
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 def search_environment_names
return [] unless params[:query] 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