summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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]