cca61980d5
This ensures that we have more visibility in the number of SQL queries that are executed in web requests. The current threshold is hardcoded to 100 as we will rarely (maybe once or twice) change it. In production and development we use Sentry if enabled, in the test environment we raise an error. This feature is also only enabled in production/staging when running on GitLab.com as it's not very useful to other users.
39 lines
1 KiB
Ruby
39 lines
1 KiB
Ruby
class Projects::CycleAnalyticsController < Projects::ApplicationController
|
|
include ActionView::Helpers::DateHelper
|
|
include ActionView::Helpers::TextHelper
|
|
include CycleAnalyticsParams
|
|
|
|
before_action :whitelist_query_limiting, only: [:show]
|
|
before_action :authorize_read_cycle_analytics!
|
|
|
|
def show
|
|
@cycle_analytics = ::CycleAnalytics.new(@project, options(cycle_analytics_params))
|
|
|
|
@cycle_analytics_no_data = @cycle_analytics.no_stats?
|
|
|
|
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?
|
|
|
|
params[:cycle_analytics].permit(:start_date)
|
|
end
|
|
|
|
def cycle_analytics_json
|
|
{
|
|
summary: @cycle_analytics.summary,
|
|
stats: @cycle_analytics.stats,
|
|
permissions: @cycle_analytics.permissions(user: current_user)
|
|
}
|
|
end
|
|
|
|
def whitelist_query_limiting
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-ce/issues/42671')
|
|
end
|
|
end
|