Commit eeaf7407 authored by Magdalena Frankiewicz's avatar Magdalena Frankiewicz Committed by Andy Soiron

Refactor cycle analytics summary base classes

Refactor to avoid multiple identical definitions of `links`, `identifier`,
`title` and `value`.
parent b57293d4
......@@ -5,6 +5,8 @@ module Gitlab
module CycleAnalytics
module Summary
class BaseTime
include Gitlab::CycleAnalytics::Summary::Defaults
def initialize(stage:, current_user:, options:)
@stage = stage
@current_user = current_user
......@@ -13,10 +15,6 @@ module Gitlab
assign_stage_metadata
end
def identifier
self.class.name.demodulize.underscore.to_sym
end
def value
@value ||= Gitlab::CycleAnalytics::Summary::Value::PrettyNumeric.new(data_collector.median.days&.round(1))
end
......@@ -33,10 +31,6 @@ module Gitlab
raise NotImplementedError, "Expected #{self.name} to implement end_event_identifier"
end
def links
[]
end
private
# rubocop: disable CodeReuse/ActiveRecord
......
......@@ -6,28 +6,14 @@ module Gitlab
module Summary
module Group
class Base
include Gitlab::CycleAnalytics::Summary::Defaults
attr_reader :group, :options
def initialize(group:, options:)
@group = group
@options = options
end
def identifier
self.class.name.demodulize.underscore.to_sym
end
def title
raise NotImplementedError, "Expected #{self.name} to implement title"
end
def value
raise NotImplementedError, "Expected #{self.name} to implement value"
end
def links
[]
end
end
end
end
......
......@@ -25,10 +25,6 @@ module Gitlab
n_('day', 'days', value)
end
def links
[]
end
private
attr_reader :stage, :current_user, :options, :from, :to
......
......@@ -4,27 +4,13 @@ module Gitlab
module CycleAnalytics
module Summary
class Base
include Gitlab::CycleAnalytics::Summary::Defaults
def initialize(project:, options:)
@project = project
@options = options
end
def identifier
self.class.name.demodulize.underscore.to_sym
end
def title
raise NotImplementedError, "Expected #{self.name} to implement title"
end
def value
raise NotImplementedError, "Expected #{self.name} to implement value"
end
def links
[]
end
private
attr_reader :project, :options
......
# frozen_string_literal: true
module Gitlab
module CycleAnalytics
module Summary
module Defaults
def identifier
self.class.name.demodulize.underscore.to_sym
end
# :nocov: the class including this concern is expected to test this method.
def title
raise NotImplementedError, "Expected #{self.name} to implement title"
end
# :nocov:
# :nocov: the class including this concern is expected to test this method.
def value
raise NotImplementedError, "Expected #{self.name} to implement value"
end
# :nocov:
def links
[]
end
end
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