2016-08-25 05:02:27 +00:00
|
|
|
class CycleAnalytics
|
2016-11-21 09:48:07 +00:00
|
|
|
STAGES = %i[issue plan code test review staging production].freeze
|
|
|
|
|
2016-11-18 15:38:02 +00:00
|
|
|
def initialize(project, from:)
|
2016-09-16 06:04:49 +00:00
|
|
|
@project = project
|
2016-11-18 15:38:02 +00:00
|
|
|
@options = options
|
2016-09-19 09:30:55 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def summary
|
2016-11-22 10:46:02 +00:00
|
|
|
@summary ||= Gitlab::CycleAnalytics::Summary.new(@project, from: @options[:from]).data
|
2016-08-26 10:15:00 +00:00
|
|
|
end
|
|
|
|
|
2016-11-18 15:38:02 +00:00
|
|
|
def method_missing(method_sym, *arguments, &block)
|
|
|
|
classify_stage(method_sym).new(project: @project, options: @options, stage: method_sym)
|
2016-11-22 11:01:21 +00:00
|
|
|
end
|
|
|
|
|
2016-11-21 13:09:26 +00:00
|
|
|
def permissions(user:)
|
|
|
|
Gitlab::CycleAnalytics::Permissions.get(user: user, project: @project)
|
2016-11-21 09:48:07 +00:00
|
|
|
end
|
|
|
|
|
2016-08-25 05:02:27 +00:00
|
|
|
def issue
|
2016-11-17 12:22:27 +00:00
|
|
|
@fetcher.calculate_metric(:issue,
|
2016-11-22 11:01:21 +00:00
|
|
|
Issue.arel_table[:created_at],
|
|
|
|
[Issue::Metrics.arel_table[:first_associated_with_milestone_at],
|
|
|
|
Issue::Metrics.arel_table[:first_added_to_board_at]])
|
2016-08-25 05:02:27 +00:00
|
|
|
end
|
|
|
|
|
2016-11-18 15:38:02 +00:00
|
|
|
def classify_stage(method_sym)
|
|
|
|
"Gitlab::CycleAnalytics::#{method_sym.to_s.capitalize}Stage".constantize
|
2016-08-25 09:06:01 +00:00
|
|
|
end
|
2016-08-25 05:02:27 +00:00
|
|
|
end
|