Module: Gitlab::Analytics::CycleAnalytics::DefaultStages

Defined in:
lib/gitlab/analytics/cycle_analytics/default_stages.rb

Class Method Summary collapse

Class Method Details

.allObject


14
15
16
17
18
19
20
21
22
23
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 14

def self.all
  [
    params_for_issue_stage,
    params_for_plan_stage,
    params_for_code_stage,
    params_for_test_stage,
    params_for_review_stage,
    params_for_staging_stage
  ]
end

.find_by_name!(name) ⇒ Object


25
26
27
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 25

def self.find_by_name!(name)
  all.find { |raw_stage| raw_stage[:name].to_s.eql?(name.to_s) } || raise("Default stage '#{name}' not found")
end

.namesObject


29
30
31
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 29

def self.names
  all.map { |stage| stage[:name] }
end

.params_for_code_stageObject


57
58
59
60
61
62
63
64
65
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 57

def self.params_for_code_stage
  {
    name: 'code',
    custom: false,
    relative_position: 3,
    start_event_identifier: :code_stage_start,
    end_event_identifier: :merge_request_created
  }
end

.params_for_issue_stageObject


37
38
39
40
41
42
43
44
45
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 37

def self.params_for_issue_stage
  {
    name: 'issue',
    custom: false, # this stage won't be customizable, we provide it as it is
    relative_position: 1, # when opening the CycleAnalytics page in CE, this stage will be the first item
    start_event_identifier: :issue_created, # IssueCreated class is used as start event
    end_event_identifier: :issue_stage_end # IssueStageEnd class is used as end event
  }
end

.params_for_plan_stageObject


47
48
49
50
51
52
53
54
55
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 47

def self.params_for_plan_stage
  {
    name: 'plan',
    custom: false,
    relative_position: 2,
    start_event_identifier: :plan_stage_start,
    end_event_identifier: :issue_first_mentioned_in_commit
  }
end

.params_for_review_stageObject


77
78
79
80
81
82
83
84
85
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 77

def self.params_for_review_stage
  {
    name: 'review',
    custom: false,
    relative_position: 5,
    start_event_identifier: :merge_request_created,
    end_event_identifier: :merge_request_merged
  }
end

.params_for_staging_stageObject


87
88
89
90
91
92
93
94
95
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 87

def self.params_for_staging_stage
  {
    name: 'staging',
    custom: false,
    relative_position: 6,
    start_event_identifier: :merge_request_merged,
    end_event_identifier: :merge_request_first_deployed_to_production
  }
end

.params_for_test_stageObject


67
68
69
70
71
72
73
74
75
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 67

def self.params_for_test_stage
  {
    name: 'test',
    custom: false,
    relative_position: 4,
    start_event_identifier: :merge_request_last_build_started,
    end_event_identifier: :merge_request_last_build_finished
  }
end

.symbolized_stage_namesObject


33
34
35
# File 'lib/gitlab/analytics/cycle_analytics/default_stages.rb', line 33

def self.symbolized_stage_names
  names.map(&:to_sym)
end