Add code review remarks
This commit is contained in:
parent
08cf6fccfd
commit
f6423fa468
4 changed files with 8 additions and 14 deletions
|
@ -4,14 +4,16 @@ module CycleAnalytics
|
|||
class Base
|
||||
STAGES = %i[issue plan code test review staging production].freeze
|
||||
|
||||
def all_medians_per_stage
|
||||
def all_medians_by_stage
|
||||
STAGES.each_with_object({}) do |stage_name, medians_per_stage|
|
||||
medians_per_stage[stage_name] = self[stage_name].median
|
||||
end
|
||||
end
|
||||
|
||||
def stats
|
||||
@stats ||= stats_per_stage
|
||||
@stats ||= STAGES.map do |stage_name|
|
||||
self[stage_name].as_json
|
||||
end
|
||||
end
|
||||
|
||||
def no_stats?
|
||||
|
@ -21,13 +23,5 @@ module CycleAnalytics
|
|||
def [](stage_name)
|
||||
Gitlab::CycleAnalytics::Stage[stage_name].new(project: @project, options: @options)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def stats_per_stage
|
||||
STAGES.map do |stage_name|
|
||||
self[stage_name].as_json
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
module CycleAnalytics
|
||||
class ProjectLevel < Base
|
||||
def initialize(project:, options:)
|
||||
def initialize(project, options:)
|
||||
@project = project
|
||||
@options = options
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ module Gitlab
|
|||
|
||||
def medians_per_stage
|
||||
projects.each_with_object({}) do |project, hsh|
|
||||
::CycleAnalytics::ProjectLevel.new(project: project, options: options).all_medians_per_stage.each do |stage_name, median|
|
||||
::CycleAnalytics::ProjectLevel.new(project: project, options: options).all_medians_by_stage.each do |stage_name, median|
|
||||
hsh[stage_name] ||= []
|
||||
hsh[stage_name] << median
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ describe CycleAnalytics::ProjectLevel do
|
|||
|
||||
subject { described_class.new(project: project, options: { from: from_date }) }
|
||||
|
||||
describe '#all_medians_per_stage' do
|
||||
describe '#all_medians_by_stage' do
|
||||
before do
|
||||
allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue])
|
||||
|
||||
|
@ -26,7 +26,7 @@ describe CycleAnalytics::ProjectLevel do
|
|||
hsh[stage_name] = subject[stage_name].median.presence
|
||||
end
|
||||
|
||||
expect(subject.all_medians_per_stage).to eq(values)
|
||||
expect(subject.all_medians_by_stage).to eq(values)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue