Welcome to mirror list, hosted at ThFree Co, Russian Federation.

base_embed_service.rb « dashboard « metrics « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4c7fa454460238fddbb421e3e7f0c267db035f90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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 self.embedded?(embed_param)
        ActiveModel::Type::Boolean.new.cast(embed_param)
      end

      def cache_key
        "dynamic_metrics_dashboard_#{identifiers}"
      end

      protected

      def dashboard_path
        params[:dashboard_path].presence ||
          ::Metrics::Dashboard::SystemDashboardService::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