2018-07-25 11:36:08 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-17 20:37:58 -04:00
|
|
|
class InstanceStatistics::CohortsController < InstanceStatistics::ApplicationController
|
2018-09-06 08:43:14 -04:00
|
|
|
before_action :authenticate_usage_ping_enabled_or_admin!
|
|
|
|
|
2017-04-05 06:24:15 -04:00
|
|
|
def index
|
2018-02-02 13:39:55 -05:00
|
|
|
if Gitlab::CurrentSettings.usage_ping_enabled
|
2017-04-06 08:12:12 -04:00
|
|
|
cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
|
2017-04-05 06:24:15 -04:00
|
|
|
CohortsService.new.execute
|
|
|
|
end
|
2017-04-06 08:12:12 -04:00
|
|
|
|
|
|
|
@cohorts = CohortsSerializer.new.represent(cohorts_results)
|
2017-04-05 06:24:15 -04:00
|
|
|
end
|
|
|
|
end
|
2018-09-06 08:43:14 -04:00
|
|
|
|
|
|
|
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
|