Commit f6423fa4 authored by Małgorzata Ksionek's avatar Małgorzata Ksionek

Add code review remarks

parent 08cf6fcc
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment