Class: Gitlab::Usage::Metrics::NameSuggestion

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/usage/metrics/name_suggestion.rb

Constant Summary collapse

FREE_TEXT_METRIC_NAME =
"<please fill metric name>"
REDIS_EVENT_METRIC_NAME =
"<please fill metric name, suggested format is: {subject}_{verb}{ing|ed}_{object} eg: users_creating_epics or merge_requests_viewed_in_single_file_mode>"
CONSTRAINTS_PROMPT_TEMPLATE =
"<adjective describing: '%{constraints}'>"

Class Method Summary collapse

Class Method Details

.for(operation, relation: nil, column: nil) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/usage/metrics/name_suggestion.rb', line 12

def for(operation, relation: nil, column: nil)
  case operation
  when :count
    name_suggestion(column: column, relation: relation, prefix: 'count')
  when :distinct_count
    name_suggestion(column: column, relation: relation, prefix: 'count_distinct', distinct: :distinct)
  when :estimate_batch_distinct_count
    name_suggestion(column: column, relation: relation, prefix: 'estimate_distinct_count')
  when :sum
    name_suggestion(column: column, relation: relation, prefix: 'sum')
  when :redis
    REDIS_EVENT_METRIC_NAME
  when :alt
    FREE_TEXT_METRIC_NAME
  else
    raise ArgumentError, "#{operation} operation not supported"
  end
end