diff options
author | Luke Bennett <lukeeeebennettplus@gmail.com> | 2018-07-18 01:37:58 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-07-27 15:54:26 +0200 |
commit | 602a1c34e33d75940c7acbf4a31a65e187dbbfde (patch) | |
tree | 580e136cf3a00cd15ade56447928ece7ad127f2c /app/controllers/instance_statistics | |
parent | ed81ee9ba2b5a0b68996ccb238bfa4c69a6df062 (diff) | |
download | gitlab-ce-602a1c34e33d75940c7acbf4a31a65e187dbbfde.tar.gz |
Create instance_statistics namespace and move convdev index and cohorts to it
Diffstat (limited to 'app/controllers/instance_statistics')
3 files changed, 32 insertions, 0 deletions
diff --git a/app/controllers/instance_statistics/application_controller.rb b/app/controllers/instance_statistics/application_controller.rb new file mode 100644 index 00000000000..2077b71bf2d --- /dev/null +++ b/app/controllers/instance_statistics/application_controller.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +class InstanceStatistics::ApplicationController < ApplicationController + before_action :authenticate_user! + layout 'instance_statistics' + + def index + redirect_to instance_statistics_conversations_development_index_index_path + end + + def authenticate_user! + render_404 unless current_user.admin? + end +end diff --git a/app/controllers/instance_statistics/cohorts_controller.rb b/app/controllers/instance_statistics/cohorts_controller.rb new file mode 100644 index 00000000000..77d09c198c8 --- /dev/null +++ b/app/controllers/instance_statistics/cohorts_controller.rb @@ -0,0 +1,11 @@ +class InstanceStatistics::CohortsController < InstanceStatistics::ApplicationController + 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 +end diff --git a/app/controllers/instance_statistics/conversational_development_index_controller.rb b/app/controllers/instance_statistics/conversational_development_index_controller.rb new file mode 100644 index 00000000000..d6d2191849f --- /dev/null +++ b/app/controllers/instance_statistics/conversational_development_index_controller.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class InstanceStatistics::ConversationalDevelopmentIndexController < InstanceStatistics::ApplicationController + def index + @metric = ConversationalDevelopmentIndex::Metric.order(:created_at).last&.present + end +end |