class Admins::SchoolBaseStatisticsController < Admins::BaseController
  before_action :must_admin!

  def index
    params[:sort_by] = params[:sort_by].presence || :teacher_count
    params[:sort_direction] = params[:sort_direction].presence || :desc

    total_count, statistics = Admins::SchoolBaseStatisticService.call(params)

    @statistics = paginate statistics, total_count: total_count
    @params_page = params[:page] || 1

    respond_to do |format|
      format.html
      format.js
    end
  end
end
