summaryrefslogtreecommitdiff
path: root/app/controllers/admin/cohorts_controller.rb
blob: 3948d3635fe011fd334d854a6db14c2a029acb9b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

class Admin::CohortsController < Admin::ApplicationController
  include ProductAnalyticsTracking

  feature_category :devops_reports

  urgency :low

  track_event :index,
    name: 'i_analytics_cohorts',
    action: 'perform_analytics_usage_action',
    label: 'redis_hll_counters.analytics.analytics_total_unique_counts_monthly',
    destinations: %i[redis_hll snowplow]

  def index
    @cohorts = load_cohorts
  end

  private

  def load_cohorts
    cohorts_results = Rails.cache.fetch('cohorts', expires_in: 1.day) do
      CohortsService.new.execute
    end

    CohortsSerializer.new.represent(cohorts_results)
  end

  def tracking_namespace_source
    nil
  end

  def tracking_project_source
    nil
  end
end