2016-11-18 15:38:02 +00:00
|
|
|
module Gitlab
|
|
|
|
module CycleAnalytics
|
|
|
|
class BaseStage
|
2016-11-21 16:15:25 +00:00
|
|
|
attr_reader :stage, :description
|
|
|
|
|
2016-11-22 09:33:19 +00:00
|
|
|
def initialize(project:, options:, stage:)
|
2016-11-18 15:38:02 +00:00
|
|
|
@project = project
|
|
|
|
@options = options
|
|
|
|
@fetcher = Gitlab::CycleAnalytics::MetricsFetcher.new(project: project,
|
|
|
|
from: options[:from],
|
|
|
|
branch: options[:branch])
|
|
|
|
@stage = stage
|
|
|
|
end
|
|
|
|
|
|
|
|
def events
|
2016-11-23 10:28:28 +00:00
|
|
|
event_class.new(fetcher: @fetcher, stage: @stage, options: @options).fetch
|
2016-11-18 15:38:02 +00:00
|
|
|
end
|
|
|
|
|
2016-11-22 09:33:19 +00:00
|
|
|
def median_data
|
|
|
|
AnalyticsStageSerializer.new.represent(self).as_json
|
|
|
|
end
|
|
|
|
|
2016-11-18 15:38:02 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def event_class
|
|
|
|
"Gitlab::CycleAnalytics::#{@stage.to_s.capitalize}Event".constantize
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|