2016-11-18 15:38:02 +00:00
|
|
|
module Gitlab
|
|
|
|
module CycleAnalytics
|
|
|
|
class BaseStage
|
2016-12-05 08:47:10 +00:00
|
|
|
include MetricsTables
|
|
|
|
|
2016-12-02 16:09:29 +00:00
|
|
|
attr_accessor :start_time_attrs, :end_time_attrs
|
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],
|
2016-12-02 16:09:29 +00:00
|
|
|
branch: options[:branch],
|
|
|
|
stage: self)
|
|
|
|
end
|
|
|
|
|
|
|
|
def event
|
2016-12-05 08:47:10 +00:00
|
|
|
@event ||= Gitlab::CycleAnalytics::Event[stage].new(fetcher: @fetcher, options: @options, stage: stage)
|
2016-11-18 15:38:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def events
|
2016-12-02 16:09:29 +00:00
|
|
|
event.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
|
2016-12-02 16:09:29 +00:00
|
|
|
@fetcher.median
|
2016-12-01 10:21:24 +00:00
|
|
|
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
|