2016-11-18 15:38:02 +00:00
|
|
|
module Gitlab
|
|
|
|
module CycleAnalytics
|
|
|
|
class BaseStage
|
2016-12-01 10:21:24 +00:00
|
|
|
include ClassNameUtil
|
2016-11-21 16:15:25 +00:00
|
|
|
|
2016-12-01 10:21:24 +00:00
|
|
|
def initialize(project:, options:)
|
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])
|
|
|
|
end
|
|
|
|
|
|
|
|
def events
|
2016-12-01 10:21:24 +00:00
|
|
|
Gitlab::CycleAnalytics::Event[stage].new(fetcher: @fetcher, 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-12-01 10:21:24 +00:00
|
|
|
def title
|
|
|
|
stage.to_s.capitalize
|
|
|
|
end
|
|
|
|
|
|
|
|
def median
|
|
|
|
raise NotImplementedError.new("Expected #{self.name} to implement median")
|
|
|
|
end
|
|
|
|
|
2016-11-18 15:38:02 +00:00
|
|
|
private
|
|
|
|
|
2016-12-01 10:21:24 +00:00
|
|
|
def stage
|
|
|
|
class_name_for('Stage')
|
2016-11-18 15:38:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|