diff options
author | rpereira2 <rpereira@gitlab.com> | 2019-04-17 12:46:11 +0300 |
---|---|---|
committer | syasonik <syasonik@gitlab.com> | 2019-04-24 13:23:03 +0300 |
commit | 4a9002cee3c80a9de24f01a5eb313ff17d2e4931 (patch) | |
tree | 922be7c059a53487e58025bf6836a2009d9c19c0 /app/controllers | |
parent | b209fb6fb21369b381e4a538f2e46ef1b6579aed (diff) |
Inherit from BaseService
Change MetricsDashboard::Service to inherit from BaseService so that
it can reuse methods like initialize, success, error.
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb index 69ceeab5b99..25815b92a0f 100644 --- a/app/controllers/projects/environments_controller.rb +++ b/app/controllers/projects/environments_controller.rb @@ -162,9 +162,19 @@ class Projects::EnvironmentsController < Projects::ApplicationController respond_to do |format| format.json do - dashboard = Gitlab::MetricsDashboard::Service.new(@project).get_dashboard - - render json: dashboard, status: :ok + result = Gitlab::MetricsDashboard::Service.new(@project).get_dashboard + + if result[:status] == :success + render status: :ok, json: { + status: :success, + dashboard: result[:dashboard] + } + else + render status: result[:http_status] || :bad_request, json: { + message: result[:message], + status: result[:status] + } + end end end end |