summaryrefslogtreecommitdiff
path: root/app/controllers/concerns/metrics_dashboard.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/concerns/metrics_dashboard.rb')
-rw-r--r--app/controllers/concerns/metrics_dashboard.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/controllers/concerns/metrics_dashboard.rb b/app/controllers/concerns/metrics_dashboard.rb
index 62efdacb710..b06b5d5a30c 100644
--- a/app/controllers/concerns/metrics_dashboard.rb
+++ b/app/controllers/concerns/metrics_dashboard.rb
@@ -3,21 +3,24 @@
# Provides an action which fetches a metrics dashboard according
# to the parameters specified by the controller.
module MetricsDashboard
+ include RenderServiceResults
extend ActiveSupport::Concern
def metrics_dashboard
result = dashboard_finder.find(
project_for_dashboard,
current_user,
- metrics_dashboard_params
+ metrics_dashboard_params.to_h.symbolize_keys
)
- if include_all_dashboards?
+ if include_all_dashboards? && result
result[:all_dashboards] = dashboard_finder.find_all_paths(project_for_dashboard)
end
respond_to do |format|
- if result[:status] == :success
+ if result.nil?
+ format.json { continue_polling_response }
+ elsif result[:status] == :success
format.json { render dashboard_success_response(result) }
else
format.json { render dashboard_error_response(result) }
@@ -56,7 +59,7 @@ module MetricsDashboard
def dashboard_error_response(result)
{
- status: result[:http_status],
+ status: result[:http_status] || :bad_request,
json: result.slice(:all_dashboards, :message, :status)
}
end