debian-mirror-gitlab/lib/gitlab/usage/metrics/names_suggestions/generator.rb

52 lines
1.7 KiB
Ruby
Raw Normal View History

2021-04-17 20:07:23 +05:30
# frozen_string_literal: true
module Gitlab
module Usage
module Metrics
module NamesSuggestions
class Generator < ::Gitlab::UsageData
class << self
def generate(key_path)
uncached_data.deep_stringify_keys.dig(*key_path.split('.'))
end
private
def count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:count, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def distinct_count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:distinct_count, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def redis_usage_counter
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:redis)
2021-04-17 20:07:23 +05:30
end
def alt_usage_data(*)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:alt)
2021-04-17 20:07:23 +05:30
end
def redis_usage_data_totals(counter)
2021-09-04 01:27:46 +05:30
counter.fallback_totals.transform_values { |_| Gitlab::Usage::Metrics::NameSuggestion.for(:redis) }
2021-04-17 20:07:23 +05:30
end
def sum(relation, column, *rest)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:sum, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def estimate_batch_distinct_count(relation, column = nil, *rest)
2021-09-04 01:27:46 +05:30
Gitlab::Usage::Metrics::NameSuggestion.for(:estimate_batch_distinct_count, column: column, relation: relation)
2021-04-17 20:07:23 +05:30
end
def add(*args)
"add_#{args.join('_and_')}"
end
end
end
end
end
end
end