2019-07-04 11:18:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module CycleAnalytics
|
2019-07-16 09:38:19 +00:00
|
|
|
module LevelBase
|
2019-07-04 11:18:33 +00:00
|
|
|
STAGES = %i[issue plan code test review staging production].freeze
|
|
|
|
|
2019-07-08 08:26:02 +00:00
|
|
|
def all_medians_by_stage
|
2019-07-04 11:18:33 +00:00
|
|
|
STAGES.each_with_object({}) do |stage_name, medians_per_stage|
|
2019-07-04 14:42:31 +00:00
|
|
|
medians_per_stage[stage_name] = self[stage_name].project_median
|
2019-07-04 11:18:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def stats
|
2019-07-08 08:26:02 +00:00
|
|
|
@stats ||= STAGES.map do |stage_name|
|
|
|
|
self[stage_name].as_json
|
|
|
|
end
|
2019-07-04 11:18:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def no_stats?
|
|
|
|
stats.all? { |hash| hash[:value].nil? }
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](stage_name)
|
2019-07-04 14:42:31 +00:00
|
|
|
Gitlab::CycleAnalytics::Stage[stage_name].new(options: options)
|
2019-07-04 11:18:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|