2016-08-24 11:17:15 -04:00
|
|
|
class Projects::CycleAnalyticsController < Projects::ApplicationController
|
2016-09-20 09:20:48 -04:00
|
|
|
include ActionView::Helpers::DateHelper
|
2016-09-21 00:27:14 -04:00
|
|
|
include ActionView::Helpers::TextHelper
|
2016-11-07 04:08:18 -05:00
|
|
|
include CycleAnalyticsParams
|
2016-09-17 02:38:23 -04:00
|
|
|
|
2018-01-15 10:21:04 -05:00
|
|
|
before_action :whitelist_query_limiting, only: [:show]
|
2016-08-26 06:54:30 -04:00
|
|
|
before_action :authorize_read_cycle_analytics!
|
|
|
|
|
2016-08-24 11:17:15 -04:00
|
|
|
def show
|
2016-12-01 05:21:24 -05:00
|
|
|
@cycle_analytics = ::CycleAnalytics.new(@project, options(cycle_analytics_params))
|
2016-11-22 08:29:25 -05:00
|
|
|
|
|
|
|
@cycle_analytics_no_data = @cycle_analytics.no_stats?
|
2016-09-08 05:33:38 -04:00
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html
|
2016-09-20 09:20:48 -04:00
|
|
|
format.json { render json: cycle_analytics_json }
|
2016-09-08 05:33:38 -04:00
|
|
|
end
|
2016-08-26 06:48:52 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def cycle_analytics_params
|
|
|
|
return {} unless params[:cycle_analytics].present?
|
|
|
|
|
2016-12-01 05:21:24 -05:00
|
|
|
params[:cycle_analytics].permit(:start_date)
|
2016-08-24 11:17:15 -04:00
|
|
|
end
|
2016-09-20 09:20:48 -04:00
|
|
|
|
2016-11-22 05:46:02 -05:00
|
|
|
def cycle_analytics_json
|
|
|
|
{
|
|
|
|
summary: @cycle_analytics.summary,
|
2016-11-22 08:29:25 -05:00
|
|
|
stats: @cycle_analytics.stats,
|
|
|
|
permissions: @cycle_analytics.permissions(user: current_user)
|
2016-09-20 09:20:48 -04:00
|
|
|
}
|
2016-11-21 09:39:43 -05:00
|
|
|
end
|
2018-01-15 10:21:04 -05:00
|
|
|
|
|
|
|
def whitelist_query_limiting
|
|
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42671')
|
|
|
|
end
|
2016-08-24 11:17:15 -04:00
|
|
|
end
|