summaryrefslogtreecommitdiff
path: root/app/services/metrics/dashboard/base_embed_service.rb
blob: 8bb5f4892cbb293f24c1e3851d4bbb41e3b347d4 (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
# 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