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

41 lines
1 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-07-28 23:09:34 +05:30
include Analytics::UniqueVisitsHelper
2020-10-24 23:57:45 +05:30
include GracefulTimeoutHandling
2016-09-29 09:46:39 +05:30
before_action :authorize_read_cycle_analytics!
2020-07-28 23:09:34 +05:30
track_unique_visits :show, target_id: 'p_analytics_valuestream'
2021-01-03 14:25:43 +05:30
feature_category :planning_analytics
2016-09-29 09:46:39 +05:30
def show
2019-12-21 20:55:43 +05:30
@cycle_analytics = ::CycleAnalytics::ProjectLevel.new(@project, options: options(cycle_analytics_project_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
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