gitlab-org--gitlab-foss/app/services/metrics/dashboard/base_embed_service.rb
Sarah Yasonik bf918b68f6 Support dashboard params for metrics dashboard
https://gitlab.com/gitlab-org/gitlab-ce/issues/62971

Adds support to EnvironmentsController#metrics_dashboard
for the following params: group, title, y_label
These params are used to uniquely identify a panel on
the metrics dashboard.

Metrics are stored in several places, so this adds
utilities to find a specific panel from the database
or filesystem depending on the metric specified.

Also moves some shared utilities into separate classes,
notably default values and errors.
2019-08-07 16:17:35 +00:00

36 lines
749 B
Ruby

# frozen_string_literal: true
# Base class for embed services. Contains a few basic helper
# methods that the embed services share.
module Metrics
module Dashboard
class BaseEmbedService < ::Metrics::Dashboard::BaseService
def cache_key
"dynamic_metrics_dashboard_#{identifiers}"
end
protected
def dashboard_path
params[:dashboard_path].presence ||
::Metrics::Dashboard::SystemDashboardService::SYSTEM_DASHBOARD_PATH
end
def group
params[:group]
end
def title
params[:title]
end
def y_label
params[:y_label]
end
def identifiers
[dashboard_path, group, title, y_label].join('|')
end
end
end
end