Module: Analytics::CycleAnalytics::Stage

Extended by:
ActiveSupport::Concern
Includes:
Gitlab::Utils::StrongMemoize, RelativePositioning
Included in:
ProjectStage
Defined in:
app/models/concerns/analytics/cycle_analytics/stage.rb

Constant Summary

Constants included from RelativePositioning

RelativePositioning::IDEAL_DISTANCE, RelativePositioning::MAX_GAP, RelativePositioning::MAX_POSITION, RelativePositioning::MIN_GAP, RelativePositioning::MIN_POSITION, RelativePositioning::NoSpaceLeft, RelativePositioning::START_POSITION, RelativePositioning::STEPS

Instance Method Summary collapse

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Methods included from RelativePositioning

#max_relative_position, #min_relative_position, #move_after, #move_before, #move_between, #move_sequence_after, #move_sequence_before, #move_to_end, #move_to_start, #next_relative_position, #prev_relative_position

Instance Method Details

#default_stage?Boolean

Returns:

  • (Boolean)

78
79
80
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 78

def default_stage?
  !custom
end

#end_eventObject


46
47
48
49
50
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 46

def end_event
  strong_memoize(:end_event) do
    Gitlab::Analytics::CycleAnalytics::StageEvents[end_event_identifier].new(params_for_end_event)
  end
end

#end_event_identifier=(identifier) ⇒ Object


65
66
67
68
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 65

def end_event_identifier=(identifier)
  clear_memoization(:end_event)
  super
end

#end_event_label_based?Boolean

Returns:

  • (Boolean)

56
57
58
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 56

def end_event_label_based?
  end_event_identifier && end_event.label_based?
end

#find_with_same_parent!(id) ⇒ Object


93
94
95
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 93

def find_with_same_parent!(id)
  parent.cycle_analytics_stages.find(id)
end

#matches_with_stage_params?(stage_params) ⇒ Boolean

Returns:

  • (Boolean)

87
88
89
90
91
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 87

def matches_with_stage_params?(stage_params)
  default_stage? &&
    start_event_identifier.to_s.eql?(stage_params[:start_event_identifier].to_s) &&
    end_event_identifier.to_s.eql?(stage_params[:end_event_identifier].to_s)
end

#params_for_end_eventObject


74
75
76
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 74

def params_for_end_event
  end_event_label.present? ? { label: end_event_label } : {}
end

#params_for_start_eventObject


70
71
72
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 70

def params_for_start_event
  start_event_label.present? ? { label: start_event_label } : {}
end

#parentObject

Raises:

  • (NotImplementedError)

36
37
38
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 36

def parent
  raise NotImplementedError
end

#parent=(_) ⇒ Object

Raises:

  • (NotImplementedError)

32
33
34
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 32

def parent=(_)
  raise NotImplementedError
end

#start_eventObject


40
41
42
43
44
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 40

def start_event
  strong_memoize(:start_event) do
    Gitlab::Analytics::CycleAnalytics::StageEvents[start_event_identifier].new(params_for_start_event)
  end
end

#start_event_identifier=(identifier) ⇒ Object


60
61
62
63
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 60

def start_event_identifier=(identifier)
  clear_memoization(:start_event)
  super
end

#start_event_label_based?Boolean

Returns:

  • (Boolean)

52
53
54
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 52

def start_event_label_based?
  start_event_identifier && start_event.label_based?
end

#subject_classObject

The model class that is going to be queried, Issue or MergeRequest


83
84
85
# File 'app/models/concerns/analytics/cycle_analytics/stage.rb', line 83

def subject_class
  start_event.object_type
end