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
|
2017-08-17 22:00:37 +05:30
|
|
|
@cycle_analytics = ::CycleAnalytics.new(@project, options(cycle_analytics_params))
|
|
|
|
|
|
|
|
@cycle_analytics_no_data = @cycle_analytics.no_stats?
|
2016-09-29 09:46:39 +05:30
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
|
|
|
format.json { render json: cycle_analytics_json }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cycle_analytics_params
|
|
|
|
return {} unless params[:cycle_analytics].present?
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
params[:cycle_analytics].permit(:start_date)
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
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
|
|
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42671')
|
|
|
|
end
|
2016-09-29 09:46:39 +05:30
|
|
|
end
|