summaryrefslogtreecommitdiff
path: root/app/presenters/analytics/cycle_analytics/stage_presenter.rb
blob: d023b0c5d5500a734a26bc3cdb28e9889042d376 (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true

module Analytics
  module CycleAnalytics
    class StagePresenter < Gitlab::View::Presenter::Delegated
      def title
        extract_default_stage_attribute(:title) || name
      end

      def description
        extract_default_stage_attribute(:description) || ''
      end

      def legend
        ''
      end

      private

      def extract_default_stage_attribute(attribute)
        default_stage_attributes.dig(name.to_sym, attribute.to_sym)
      end

      def default_stage_attributes
        @default_stage_attributes ||= {
          issue: {
            title: s_('CycleAnalyticsStage|Issue'),
            description: _('Time before an issue gets scheduled')
          },
          plan: {
            title: s_('CycleAnalyticsStage|Plan'),
            description: _('Time before an issue starts implementation')
          },
          code: {
            title: s_('CycleAnalyticsStage|Code'),
            description: _('Time until first merge request')
          },
          test: {
            title: s_('CycleAnalyticsStage|Test'),
            description: _('Total test time for all commits/merges')
          },
          review: {
            title: s_('CycleAnalyticsStage|Review'),
            description: _('Time between merge request creation and merge/close')
          },
          staging: {
            title: s_('CycleAnalyticsStage|Staging'),
            description: _('From merge request merge until deploy to production')
          },
          production: {
            title: s_('CycleAnalyticsStage|Total'),
            description: _('From issue creation until deploy to production')
          }
        }.freeze
      end
    end
  end
end