Class: Gitlab::Usage::Metrics::Query

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

Class Method Summary collapse

Class Method Details

.for(operation, relation, column = nil, **extra) ⇒ Object


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/gitlab/usage/metrics/query.rb', line 8

def for(operation, relation, column = nil, **extra)
  case operation
  when :count
    count(relation, column)
  when :distinct_count
    distinct_count(relation, column)
  when :sum
    sum(relation, column)
  when :average
    average(relation, column)
  when :estimate_batch_distinct_count
    estimate_batch_distinct_count(relation, column)
  when :histogram
    histogram(relation, column, **extra)
  else
    raise ArgumentError, "#{operation} operation not supported"
  end
end