Class: GitlabInternalEventsCli::Helpers::MetricOptions::EventSelection
- Inherits:
-
Struct
- Object
- Struct
- GitlabInternalEventsCli::Helpers::MetricOptions::EventSelection
- Defined in:
- lib/gitlab_internal_events_cli/helpers/metric_options.rb
Overview
Represents the attributes of set of events that depend on the other events in the set
Instance Method Summary collapse
- #actions ⇒ Object
-
#can_filter_when_operated_on?(identifier) ⇒ Boolean
Whether there are any filtering options other than the selected uniqueness constraint.
-
#events_name ⇒ Object
Very brief summary of the provided events to use in a basic description of the metric This ignores filters for simplicity & skimability.
-
#exclude_filter_identifier?(identifier) ⇒ Boolean
Whether none of the events have additional properties and the given identifier is an additional property.
-
#filter_name(identifier) ⇒ Object
Formatted list of filter options for these events, given the provided uniqueness constraint.
-
#filter_options ⇒ Object
We accept different filters for each event, so we want any filter options available for any event.
-
#operable_identifiers ⇒ Object
We require the same uniqueness constraint for all events, so we want only the options they have in common.
-
#shared_filters ⇒ Object
Common values for filters shared across all the events.
-
#shared_identifiers ⇒ Object
Common values for identifiers shared across all the events.
-
#supports_operations?(identifier) ⇒ Boolean
Whether the given identifier is available for all events and can be used as a uniqueness constraint.
Instance Method Details
#actions ⇒ Object
123 124 125 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 123 def actions events.map(&:action) end |
#can_filter_when_operated_on?(identifier) ⇒ Boolean
Whether there are any filtering options other than the selected uniqueness constraint
156 157 158 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 156 def can_filter_when_operated_on?(identifier) supports_operations?(identifier) && .difference([identifier]).any? end |
#events_name ⇒ Object
Very brief summary of the provided events to use in a basic description of the metric This ignores filters for simplicity & skimability
130 131 132 133 134 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 130 def events_name return actions.first if actions.length == 1 "any of #{actions.length} events" end |
#exclude_filter_identifier?(identifier) ⇒ Boolean
Whether none of the events have additional properties and the given identifier is an additional property. In this case, it makes sense to exclude these from the menu to keep the flow simple when the use-case is simple
180 181 182 183 184 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 180 def exclude_filter_identifier?(identifier) return false if identifier.nil? || Metric::Identifier.new(identifier).default? .empty? end |
#filter_name(identifier) ⇒ Object
Formatted list of filter options for these events, given the provided uniqueness constraint
138 139 140 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 138 def filter_name(identifier) .difference([identifier]).join('/') end |
#filter_options ⇒ Object
We accept different filters for each event, so we want any filter options available for any event
144 145 146 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 144 def events.flat_map(&:available_filters).uniq end |
#operable_identifiers ⇒ Object
We require the same uniqueness constraint for all events, so we want only the options they have in common
150 151 152 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 150 def operable_identifiers [*shared_identifiers, *shared_filters, nil] end |
#shared_filters ⇒ Object
Common values for filters shared across all the events
172 173 174 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 172 def shared_filters events.map(&:available_filters).reduce(&:&) end |
#shared_identifiers ⇒ Object
Common values for identifiers shared across all the events
167 168 169 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 167 def shared_identifiers events.map(&:identifiers).reduce(&:&) end |
#supports_operations?(identifier) ⇒ Boolean
Whether the given identifier is available for all events and can be used as a uniqueness constraint
162 163 164 |
# File 'lib/gitlab_internal_events_cli/helpers/metric_options.rb', line 162 def supports_operations?(identifier) operable_identifiers.include?(identifier) end |