debian-mirror-gitlab/app/controllers/projects/cycle_analytics_controller.rb

57 lines
1.6 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
class Projects::CycleAnalyticsController < Projects::ApplicationController
include ActionView::Helpers::DateHelper
include ActionView::Helpers::TextHelper
2017-08-17 22:00:37 +05:30
include CycleAnalyticsParams
2020-10-24 23:57:45 +05:30
include GracefulTimeoutHandling
2021-09-30 23:02:18 +05:30
include RedisTracking
2021-12-11 22:18:48 +05:30
extend ::Gitlab::Utils::Override
2016-09-29 09:46:39 +05:30
before_action :authorize_read_cycle_analytics!
2021-12-11 22:18:48 +05:30
before_action :load_value_stream, only: :show
2016-09-29 09:46:39 +05:30
2021-09-30 23:02:18 +05:30
track_redis_hll_event :show, name: 'p_analytics_valuestream'
2020-07-28 23:09:34 +05:30
2021-01-03 14:25:43 +05:30
feature_category :planning_analytics
2021-09-30 23:02:18 +05:30
before_action do
push_licensed_feature(:cycle_analytics_for_groups) if project.licensed_feature_available?(:cycle_analytics_for_groups)
end
2016-09-29 09:46:39 +05:30
def show
2021-09-04 01:27:46 +05:30
@cycle_analytics = Analytics::CycleAnalytics::ProjectLevel.new(project: @project, options: options(cycle_analytics_project_params))
2021-12-11 22:18:48 +05:30
@request_params ||= ::Gitlab::Analytics::CycleAnalytics::RequestParams.new(all_cycle_analytics_params)
2017-08-17 22:00:37 +05:30
2016-09-29 09:46:39 +05:30
respond_to do |format|
2019-10-12 21:52:04 +05:30
format.html do
Gitlab::UsageDataCounters::CycleAnalyticsCounter.count(:views)
render :show
end
format.json do
render json: cycle_analytics_json
end
2016-09-29 09:46:39 +05:30
end
end
private
2021-12-11 22:18:48 +05:30
override :all_cycle_analytics_params
def all_cycle_analytics_params
super.merge({ project: @project, value_stream: @value_stream })
end
def load_value_stream
@value_stream = Analytics::CycleAnalytics::ProjectValueStream.build_default_value_stream(@project)
end
2016-09-29 09:46:39 +05:30
def cycle_analytics_json
{
2017-08-17 22:00:37 +05:30
summary: @cycle_analytics.summary,
stats: @cycle_analytics.stats,
permissions: @cycle_analytics.permissions(user: current_user)
2016-09-29 09:46:39 +05:30
}
end
end