app/controllers/sample_students_controller.rb
# Admin only; get a sample of students for looking at data across the site
Admin only; get a sample of students for looking at data across the site
Admin only ; get a sample of students for looking at data across the site
def sample_students_json
    seed = params.fetch(:seed, '42').to_i
    n = params.fetch(:n, '40').to_i
    authorized_sample_students = authorized do
      Student.active.sample(n, random: Random.new(seed))
    end
    sample_students_json = authorized_sample_students.as_json({
      only: [:id, :grade, :first_name, :last_name],
      include: {
        school: {
          only: [:id, :name, :school_type]
        }
      }
    })
    render json: {
      sample_students: sample_students_json
    }
  end
def sample_students_json seed = params . fetch ( :seed , '42' ) . to_i n = params . fetch ( :n , '40' ) . to_i authorized_sample_students = authorized do Student . active . sample ( n , random : Random . new ( seed ) ) end sample_students_json = authorized_sample_students . as_json ( { only : [ :id , :grade , :first_name , :last_name ] , include : { school : { only : [ :id , :name , :school_type ] } } } ) render json : { sample_students : sample_students_json } end
Admin only; get a sample of students for looking at data across the site
Admin only ; get a sample of students for looking at data across the site