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: 4b4e39db2e1fae81b7806343b69c6699bf0e8b65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class InstanceStatistics::CohortsController < InstanceStatistics::ApplicationController
  before_action :authenticate_usage_ping_enabled_or_admin!

  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