2019-09-30 21:07:59 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module CycleAnalytics
|
2019-10-12 21:52:04 +05:30
|
|
|
module LevelBase
|
2020-11-24 15:15:51 +05:30
|
|
|
STAGES = %i[issue plan code test review staging].freeze
|
2019-09-30 21:07:59 +05:30
|
|
|
|
|
|
|
def all_medians_by_stage
|
|
|
|
STAGES.each_with_object({}) do |stage_name, medians_per_stage|
|
2019-10-12 21:52:04 +05:30
|
|
|
medians_per_stage[stage_name] = self[stage_name].project_median
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def stats
|
|
|
|
@stats ||= STAGES.map do |stage_name|
|
|
|
|
self[stage_name].as_json
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def no_stats?
|
|
|
|
stats.all? { |hash| hash[:value].nil? }
|
|
|
|
end
|
|
|
|
|
|
|
|
def [](stage_name)
|
2019-10-12 21:52:04 +05:30
|
|
|
Gitlab::CycleAnalytics::Stage[stage_name].new(options: options)
|
2019-09-30 21:07:59 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|