Class: Gitlab::Analytics::CycleAnalytics::DataCollector

Inherits:
Object
  • Object
show all
Includes:
Utils::StrongMemoize
Defined in:
lib/gitlab/analytics/cycle_analytics/data_collector.rb

Overview

Arguments:

stage - an instance of CycleAnalytics::Stage
params:
  current_user: an instance of User
  from: DateTime
  to: DateTime

Constant Summary collapse

MAX_COUNT =
1001

Instance Method Summary collapse

Constructor Details

#initialize(stage:, params: {}) ⇒ DataCollector

Returns a new instance of DataCollector.



19
20
21
22
# File 'lib/gitlab/analytics/cycle_analytics/data_collector.rb', line 19

def initialize(stage:, params: {})
  @stage = stage
  @params = params
end

Instance Method Details

#averageObject



44
45
46
47
48
# File 'lib/gitlab/analytics/cycle_analytics/data_collector.rb', line 44

def average
  strong_memoize(:average) do
    Average.new(stage: stage, query: query, params: params)
  end
end

#countObject



50
51
52
53
54
55
56
57
58
# File 'lib/gitlab/analytics/cycle_analytics/data_collector.rb', line 50

def count
  strong_memoize(:count) do
    if use_aggregated_data_collector?
      aggregated_data_collector.count
    else
      limit_count
    end
  end
end

#medianObject



34
35
36
37
38
39
40
41
42
# File 'lib/gitlab/analytics/cycle_analytics/data_collector.rb', line 34

def median
  strong_memoize(:median) do
    if use_aggregated_data_collector?
      aggregated_data_collector.median
    else
      Median.new(stage: stage, query: query, params: params)
    end
  end
end

#records_fetcherObject



24
25
26
27
28
29
30
31
32
# File 'lib/gitlab/analytics/cycle_analytics/data_collector.rb', line 24

def records_fetcher
  strong_memoize(:records_fetcher) do
    if use_aggregated_data_collector?
      aggregated_data_collector.records_fetcher
    else
      RecordsFetcher.new(stage: stage, query: query, params: params)
    end
  end
end