Module: Gitlab::Analytics::CycleAnalytics::StageEvents

Defined in:
lib/gitlab/analytics/cycle_analytics/stage_events.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/stage_event.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/issue_created.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/issue_stage_end.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/code_stage_start.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/plan_stage_start.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_merged.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_created.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/metrics_based_stage_event.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/issue_deployed_to_production.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/issue_first_mentioned_in_commit.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_last_build_started.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_last_build_finished.rb,
lib/gitlab/analytics/cycle_analytics/stage_events/merge_request_first_deployed_to_production.rb

Defined Under Namespace

Classes: CodeStageStart, IssueCreated, IssueDeployedToProduction, IssueFirstMentionedInCommit, IssueStageEnd, MergeRequestCreated, MergeRequestFirstDeployedToProduction, MergeRequestLastBuildFinished, MergeRequestLastBuildStarted, MergeRequestMerged, MetricsBasedStageEvent, PlanStageStart, StageEvent

Constant Summary collapse

ENUM_MAPPING =

Convention: Issue: < 100 MergeRequest: >= 100 && < 1000 Custom events for default stages: >= 1000 (legacy)

To avoid duplications, verify that the value does not exist in ee/lib/ee/gitlab/analytics/cycle_analytics/stage_events.rb

{
  StageEvents::IssueCreated => 1,
  StageEvents::IssueFirstMentionedInCommit => 2,
  StageEvents::IssueDeployedToProduction => 10,
  StageEvents::MergeRequestCreated => 100,
  StageEvents::MergeRequestFirstDeployedToProduction => 101,
  StageEvents::MergeRequestLastBuildFinished => 102,
  StageEvents::MergeRequestLastBuildStarted => 103,
  StageEvents::MergeRequestMerged => 104,
  StageEvents::CodeStageStart => 1_000,
  StageEvents::IssueStageEnd => 1_001,
  StageEvents::PlanStageStart => 1_002
}.freeze
EVENTS =
ENUM_MAPPING.keys.freeze
INTERNAL_EVENTS =
[
  StageEvents::CodeStageStart,
  StageEvents::IssueStageEnd,
  StageEvents::PlanStageStart
].freeze
PAIRING_RULES =

Defines which start_event and end_event pairs are allowed

{
  StageEvents::PlanStageStart => [
    StageEvents::IssueFirstMentionedInCommit
  ],
  StageEvents::CodeStageStart => [
    StageEvents::MergeRequestCreated
  ],
  StageEvents::IssueCreated => [
    StageEvents::IssueStageEnd,
    StageEvents::IssueDeployedToProduction
  ],
  StageEvents::MergeRequestCreated => [
    StageEvents::MergeRequestMerged
  ],
  StageEvents::MergeRequestLastBuildStarted => [
    StageEvents::MergeRequestLastBuildFinished
  ],
  StageEvents::MergeRequestMerged => [
    StageEvents::MergeRequestFirstDeployedToProduction
  ]
}.freeze

Class Method Summary collapse

Class Method Details

.[](identifier) ⇒ Object


58
59
60
# File 'lib/gitlab/analytics/cycle_analytics/stage_events.rb', line 58

def self.[](identifier)
  events.find { |e| e.identifier.to_s.eql?(identifier.to_s) } || raise(KeyError)
end

.enum_mappingObject


75
76
77
# File 'lib/gitlab/analytics/cycle_analytics/stage_events.rb', line 75

def self.enum_mapping
  ENUM_MAPPING
end

.eventsObject


71
72
73
# File 'lib/gitlab/analytics/cycle_analytics/stage_events.rb', line 71

def self.events
  EVENTS
end

.internal_eventsObject

Events that are specific to the 7 default stages


80
81
82
# File 'lib/gitlab/analytics/cycle_analytics/stage_events.rb', line 80

def self.internal_events
  INTERNAL_EVENTS
end

.pairing_rulesObject


67
68
69
# File 'lib/gitlab/analytics/cycle_analytics/stage_events.rb', line 67

def self.pairing_rules
  PAIRING_RULES
end

.to_enumObject

hash for defining ActiveRecord enum: identifier => number


63
64
65
# File 'lib/gitlab/analytics/cycle_analytics/stage_events.rb', line 63

def self.to_enum
  enum_mapping.transform_keys { |k| k.identifier }
end