Class: GitlabInternalEventsCli::ExistingMetric
- Inherits:
-
Struct
- Object
- Struct
- GitlabInternalEventsCli::ExistingMetric
- Defined in:
- lib/gitlab_internal_events_cli/metric.rb
Overview
These keys will always be included in the definition yaml
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
Instance Method Summary collapse
- #actions ⇒ Object
- #filtered? ⇒ Boolean
- #filters ⇒ Object
- #identifier ⇒ Object
- #operator ⇒ Object
- #time_frame ⇒ Object
-
#unique_ids ⇒ Object
Enables comparison with new metrics.
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path
42 43 44 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 42 def file_path @file_path end |
Instance Method Details
#actions ⇒ Object
47 48 49 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 47 def actions events&.map { |event| event['name'] } end |
#filtered? ⇒ Boolean
57 58 59 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 57 def filtered? !!filters&.any? { |(_action, filter)| filter&.any? } end |
#filters ⇒ Object
51 52 53 54 55 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 51 def filters events&.map do |event| [event['name'], event['filter'] || {}] end end |
#identifier ⇒ Object
43 44 45 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 43 def identifier events&.dig(0, 'unique')&.chomp('.id') end |
#operator ⇒ Object
77 78 79 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 77 def operator events&.dig(0, 'operator') || "count(#{identifier})" end |
#time_frame ⇒ Object
61 62 63 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 61 def time_frame self[:time_frame] || 'all' end |
#unique_ids ⇒ Object
Enables comparison with new metrics
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/gitlab_internal_events_cli/metric.rb', line 66 def unique_ids prefix = [ operator, (actions || []).sort.join('+'), 'filter-', filtered? ].join('_') Array(time_frame).map { |t| prefix + t } end |