gitlab-org--gitlab-foss/app/controllers/instance_statistics/cohorts_controller.rb

20 lines
589 B
Ruby
Raw Normal View History

2018-07-25 11:36:08 -04:00
# frozen_string_literal: true
class InstanceStatistics::CohortsController < InstanceStatistics::ApplicationController
before_action :authenticate_usage_ping_enabled_or_admin!
2017-04-05 06:24:15 -04:00
def index
if Gitlab::CurrentSettings.usage_ping_enabled
cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
2017-04-05 06:24:15 -04:00
CohortsService.new.execute
end
@cohorts = CohortsSerializer.new.represent(cohorts_results)
2017-04-05 06:24:15 -04:00
end
end
def authenticate_usage_ping_enabled_or_admin!
render_404 unless Gitlab::CurrentSettings.usage_ping_enabled || current_user.admin?
end
2017-04-05 06:24:15 -04:00
end