Class: GitlabInternalEventsCli::ExistingMetric

Inherits:
Struct
  • Object
show all
Defined in:
lib/gitlab_internal_events_cli/metric.rb

Overview

These keys will always be included in the definition yaml

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path

Returns:

  • (Object)

    the current value of file_path



42
43
44
# File 'lib/gitlab_internal_events_cli/metric.rb', line 42

def file_path
  @file_path
end

Instance Method Details

#actionsObject



47
48
49
# File 'lib/gitlab_internal_events_cli/metric.rb', line 47

def actions
  events&.map { |event| event['name'] }
end

#filtered?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/gitlab_internal_events_cli/metric.rb', line 57

def filtered?
  !!filters&.any? { |(_action, filter)| filter&.any? }
end

#filtersObject



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

#identifierObject



43
44
45
# File 'lib/gitlab_internal_events_cli/metric.rb', line 43

def identifier
  events&.dig(0, 'unique')&.chomp('.id')
end

#operatorObject



77
78
79
# File 'lib/gitlab_internal_events_cli/metric.rb', line 77

def operator
  events&.dig(0, 'operator') || "count(#{identifier})"
end

#time_frameObject



61
62
63
# File 'lib/gitlab_internal_events_cli/metric.rb', line 61

def time_frame
  self[:time_frame] || 'all'
end

#unique_idsObject

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