Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cohorts_controller.rb « instance_statistics « controllers « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 0de62a56b01cc7e157b2cbc50405efe6fa8e8cc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# frozen_string_literal: true

class InstanceStatistics::CohortsController < InstanceStatistics::ApplicationController
  include Analytics::UniqueVisitsHelper

  before_action :authenticate_usage_ping_enabled_or_admin!

  track_unique_visits :index, target_id: 'i_analytics_cohorts'

  def index
    if Gitlab::CurrentSettings.usage_ping_enabled
      cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
        CohortsService.new.execute
      end

      @cohorts = CohortsSerializer.new.represent(cohorts_results)
    end
  end

  def authenticate_usage_ping_enabled_or_admin!
    render_404 unless Gitlab::CurrentSettings.usage_ping_enabled || current_user.admin?
  end
end