2018-09-26 03:45:43 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-24 15:17:15 +00:00
|
|
|
class Projects::CycleAnalyticsController < Projects::ApplicationController
|
2016-09-20 13:20:48 +00:00
|
|
|
include ActionView::Helpers::DateHelper
|
2016-09-21 04:27:14 +00:00
|
|
|
include ActionView::Helpers::TextHelper
|
2016-11-07 09:08:18 +00:00
|
|
|
include CycleAnalyticsParams
|
2020-06-22 15:09:27 +00:00
|
|
|
include Analytics::UniqueVisitsHelper
|
2016-09-17 06:38:23 +00:00
|
|
|
|
2018-01-15 15:21:04 +00:00
|
|
|
before_action :whitelist_query_limiting, only: [:show]
|
2016-08-26 10:54:30 +00:00
|
|
|
before_action :authorize_read_cycle_analytics!
|
|
|
|
|
2020-06-22 15:09:27 +00:00
|
|
|
track_unique_visits :show, target_id: 'p_analytics_valuestream'
|
|
|
|
|
2016-08-24 15:17:15 +00:00
|
|
|
def show
|
2019-10-07 21:07:54 +00:00
|
|
|
@cycle_analytics = ::CycleAnalytics::ProjectLevel.new(@project, options: options(cycle_analytics_project_params))
|
2016-11-22 13:29:25 +00:00
|
|
|
|
|
|
|
@cycle_analytics_no_data = @cycle_analytics.no_stats?
|
2016-09-08 09:33:38 +00:00
|
|
|
|
|
|
|
respond_to do |format|
|
2019-08-14 16:12:12 +00:00
|
|
|
format.html do
|
|
|
|
Gitlab::UsageDataCounters::CycleAnalyticsCounter.count(:views)
|
|
|
|
|
|
|
|
render :show
|
|
|
|
end
|
|
|
|
format.json do
|
|
|
|
render json: cycle_analytics_json
|
|
|
|
end
|
2016-09-08 09:33:38 +00:00
|
|
|
end
|
2016-08-26 10:48:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2016-11-22 10:46:02 +00:00
|
|
|
def cycle_analytics_json
|
|
|
|
{
|
|
|
|
summary: @cycle_analytics.summary,
|
2016-11-22 13:29:25 +00:00
|
|
|
stats: @cycle_analytics.stats,
|
|
|
|
permissions: @cycle_analytics.permissions(user: current_user)
|
2016-09-20 13:20:48 +00:00
|
|
|
}
|
2016-11-21 14:39:43 +00:00
|
|
|
end
|
2018-01-15 15:21:04 +00:00
|
|
|
|
|
|
|
def whitelist_query_limiting
|
2019-09-18 14:02:45 +00:00
|
|
|
Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab-foss/issues/42671')
|
2018-01-15 15:21:04 +00:00
|
|
|
end
|
2016-08-24 15:17:15 +00:00
|
|
|
end
|