~cytrogen/masto-fe

ref: ec59166844b04ec416bdbc2612fd8a4364f9dd67 masto-fe/app/controllers/api/v1/admin/retention_controller.rb -rw-r--r-- 546 bytes
ec591668 — Claire Fix ArgumentError when loading newer Private Mentions (#25399) 2 years ago
                                                                                
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
# frozen_string_literal: true

class Api::V1::Admin::RetentionController < Api::BaseController
  include Authorization

  before_action -> { authorize_if_got_token! :'admin:read' }
  before_action :set_cohorts

  after_action :verify_authorized

  def create
    authorize :dashboard, :index?
    render json: @cohorts, each_serializer: REST::Admin::CohortSerializer
  end

  private

  def set_cohorts
    @cohorts = Admin::Metrics::Retention.new(
      params[:start_at],
      params[:end_at],
      params[:frequency]
    ).cohorts
  end
end