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

48 lines
1.2 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
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-09-30 21:07:59 +05:30
@cycle_analytics = ::CycleAnalytics::ProjectLevel.new(@project, options: options(cycle_analytics_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_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