class Family::Covid::StudentsController < Family::Controller
  def index
    data = students
      .current_status(current_school, :current)
      .ordered
    render_success :ok, json: data.map { |s| student_props(s) }
  end

  private
    def screening_by_student
      @screening_by_student ||= current_family.covid_screenings.today.pluck(:student_id)
    end

    def student_props(student)
      {
        id: student.id,
        full_name: student.full_name,
        completed: screening_by_student.include?(student.id)
      }
    end
end
