2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Gitlab
|
|
|
|
module Analytics
|
|
|
|
module CycleAnalytics
|
|
|
|
# Arguments:
|
|
|
|
# stage - an instance of CycleAnalytics::ProjectStage or CycleAnalytics::GroupStage
|
|
|
|
# params:
|
|
|
|
# current_user: an instance of User
|
|
|
|
# from: DateTime
|
|
|
|
# to: DateTime
|
|
|
|
class DataCollector
|
|
|
|
include Gitlab::Utils::StrongMemoize
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
delegate :serialized_records, to: :records_fetcher
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
def initialize(stage:, params: {})
|
|
|
|
@stage = stage
|
|
|
|
@params = params
|
|
|
|
end
|
|
|
|
|
|
|
|
def records_fetcher
|
|
|
|
strong_memoize(:records_fetcher) do
|
|
|
|
RecordsFetcher.new(stage: stage, query: query, params: params)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def median
|
|
|
|
strong_memoize(:median) do
|
|
|
|
Median.new(stage: stage, query: query)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
def average
|
|
|
|
strong_memoize(:average) do
|
|
|
|
Average.new(stage: stage, query: query)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :stage, :params
|
|
|
|
|
|
|
|
def query
|
|
|
|
BaseQueryBuilder.new(stage: stage, params: params).build
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-01-01 13:55:28 +05:30
|
|
|
|
|
|
|
Gitlab::Analytics::CycleAnalytics::DataCollector.prepend_if_ee('EE::Gitlab::Analytics::CycleAnalytics::DataCollector')
|