summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyasonik <syasonik@gitlab.com>2019-04-19 18:37:48 +0800
committersyasonik <syasonik@gitlab.com>2019-04-24 18:23:04 +0800
commit131494f26f042c7b7ced1d9abeb405986c524d92 (patch)
tree07769945e580d7771aeb7bc68bf57561d80e8afb
parentc1c0fb66937dcea326cb70528373ce6ab822d25a (diff)
downloadgitlab-ce-131494f26f042c7b7ced1d9abeb405986c524d92.tar.gz
Refactor metrics_dashboard response conditionals
-rw-r--r--app/controllers/projects/environments_controller.rb16
1 files changed, 5 insertions, 11 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index e285011469c..36b9bb101af 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -159,12 +159,13 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def metrics_dashboard
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|
- format.json do
- result = Gitlab::MetricsDashboard::Service.new(@project, @current_user, environment: environment).get_dashboard
-
- render_metrics_dashboard_response(result)
+ 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]