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
|
2016-09-29 09:46:39 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before_action :whitelist_query_limiting, only: [:show]
|
2016-09-29 09:46:39 +05:30
|
|
|
before_action :authorize_read_cycle_analytics!
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
@cycle_analytics_no_data = @cycle_analytics.no_stats?
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
def whitelist_query_limiting
|
2019-12-04 20:38:33 +05:30
|
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42671')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|