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/production_stage_end.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_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, IssueFirstMentionedInCommit, IssueStageEnd, MergeRequestCreated, MergeRequestFirstDeployedToProduction, MergeRequestLastBuildFinished, MergeRequestLastBuildStarted, MergeRequestMerged, MetricsBasedStageEvent, PlanStageStart, ProductionStageEnd, StageEvent

Constant Summary collapse

ENUM_MAPPING =

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

{
  StageEvents::IssueCreated => 1,
  StageEvents::IssueFirstMentionedInCommit => 2,
  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,
  StageEvents::ProductionStageEnd => 1_003
}.freeze
EVENTS =
ENUM_MAPPING.keys.freeze
INTERNAL_EVENTS =
[
  StageEvents::CodeStageStart,
  StageEvents::IssueStageEnd,
  StageEvents::PlanStageStart,
  StageEvents::ProductionStageEnd
].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::ProductionStageEnd
  ],
  StageEvents::MergeRequestCreated => [
    StageEvents::MergeRequestMerged
  ],
  StageEvents::MergeRequestLastBuildStarted => [
    StageEvents::MergeRequestLastBuildFinished
  ],
  StageEvents::MergeRequestMerged => [
    StageEvents::MergeRequestFirstDeployedToProduction
  ]
}.freeze

Class Method Summary collapse

Class Method Details

.[](identifier) ⇒ Object


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

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

.enum_mappingObject


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

def self.enum_mapping
  ENUM_MAPPING
end

.eventsObject


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

def self.events
  EVENTS
end

.internal_eventsObject

Events that are specific to the 7 default stages


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

def self.internal_events
  INTERNAL_EVENTS
end

.pairing_rulesObject


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

def self.pairing_rules
  PAIRING_RULES
end

.to_enumObject

hash for defining ActiveRecord enum: identifier => number


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

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