summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorrpereira2 <rpereira@gitlab.com>2019-04-17 15:16:11 +0530
committersyasonik <syasonik@gitlab.com>2019-04-24 18:23:03 +0800
commit4a9002cee3c80a9de24f01a5eb313ff17d2e4931 (patch)
tree922be7c059a53487e58025bf6836a2009d9c19c0 /app/controllers
parentb209fb6fb21369b381e4a538f2e46ef1b6579aed (diff)
downloadgitlab-ce-4a9002cee3c80a9de24f01a5eb313ff17d2e4931.tar.gz
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.rb16
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