2016-08-25 01:02:27 -04:00
|
|
|
class CycleAnalytics
|
2016-11-21 04:48:07 -05:00
|
|
|
STAGES = %i[issue plan code test review staging production].freeze
|
|
|
|
|
2016-12-01 05:21:24 -05:00
|
|
|
def initialize(project, options)
|
2016-09-16 02:04:49 -04:00
|
|
|
@project = project
|
2016-11-18 10:38:02 -05:00
|
|
|
@options = options
|
2016-09-19 05:30:55 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def summary
|
2016-12-01 07:28:24 -05:00
|
|
|
@summary ||= ::Gitlab::CycleAnalytics::StageSummary.new(@project,
|
|
|
|
from: @options[:from],
|
|
|
|
current_user: @options[:current_user]).data
|
2016-08-26 06:15:00 -04:00
|
|
|
end
|
|
|
|
|
2016-11-22 08:29:25 -05:00
|
|
|
def stats
|
|
|
|
@stats ||= stats_per_stage
|
|
|
|
end
|
|
|
|
|
|
|
|
def no_stats?
|
2017-01-12 08:32:30 -05:00
|
|
|
stats.all? { |hash| hash[:value].nil? }
|
2016-11-22 06:01:21 -05:00
|
|
|
end
|
|
|
|
|
2016-11-21 08:09:26 -05:00
|
|
|
def permissions(user:)
|
|
|
|
Gitlab::CycleAnalytics::Permissions.get(user: user, project: @project)
|
2016-11-21 04:48:07 -05:00
|
|
|
end
|
|
|
|
|
2016-12-01 05:21:24 -05:00
|
|
|
def [](stage_name)
|
|
|
|
Gitlab::CycleAnalytics::Stage[stage_name].new(project: @project, options: @options)
|
2016-11-23 05:28:28 -05:00
|
|
|
end
|
|
|
|
|
2016-11-22 08:29:25 -05:00
|
|
|
private
|
|
|
|
|
|
|
|
def stats_per_stage
|
|
|
|
STAGES.map do |stage_name|
|
2017-01-12 06:48:01 -05:00
|
|
|
self[stage_name].as_json
|
2016-11-22 08:29:25 -05:00
|
|
|
end
|
2016-08-25 01:02:27 -04:00
|
|
|
end
|
|
|
|
end
|