<commit_before>module Papyrus
  class StudentLoader

    DEFAULT_OPTIONS = {
      ignore_first_line: true,
      fields_order: [
        "student_number",
        "first_name",
        "last_name",
        "email",
        "cds_counsellor",
        "cds_counsellor_email",
        "accessibility_lab_access",
        "book_retrieval",
        "alternate_format_required",
        "format_pdf",
        "format_large_print",
        "format_word",
        "format_braille",
        "format_other",
        "format_note",
        "request_form_signed_on"
      ],
      coordinator_id: 1,
      created_by_id: 1
    }

    def initialize
      @options = DEFAULT_OPTIONS
    end


    def from_list(students_list, options=nil)
      
      return nil if students_list == nil || !students_list.kind_of?(Array) # If nil or array return

      process_options(options)

      # ignore first line if required
      students_list.shift if @options[:ignore_first_line]

      ## GET COORDINATOR LIST, for later processing
      coordinator_list = User.active.coordinators.collect { |u| u.id }
      ## ENSURE first id in the list is not the most recent assigned coordinator
      if Student.most_recent_students(1).size > 0
        last_assigned_coordinator_id = Student.most_recent_students(1).first.details.transcription_coordinator_id
        if last_assigned_coordinator_id == coordinator_list.last
          id = coordinator_list.pop
          coordinator_list.insert(0, id)
        end
      end

      status = { updated: [], created: [], errors: [] }

      students_list.each do |student_array|

        params = Student.build_hash_from_array(student_array, @options[:fields_order])
        student = Student.where("student_details.student_number = ?", params[:student_details_attributes][:student_number]).references(:student_details).includes(:student_details).first<commit_msg>Removed the coordinator recency check for now<commit_after>module Papyrus
  class StudentLoader

    DEFAULT_OPTIONS = {
      ignore_first_line: true,
      fields_order: [
        "student_number",
        "first_name",
        "last_name",
        "email",
        "cds_counsellor",
        "cds_counsellor_email",
        "accessibility_lab_access",
        "book_retrieval",
        "alternate_format_required",
        "format_pdf",
        "format_large_print",
        "format_word",
        "format_braille",
        "format_other",
        "format_note",
        "request_form_signed_on"
      ],
      coordinator_id: 1,
      created_by_id: 1
    }

    def initialize
      @options = DEFAULT_OPTIONS
    end


    def from_list(students_list, options=nil)

      return nil if students_list == nil || !students_list.kind_of?(Array) # If nil or array return

      process_options(options)

      # ignore first line if required
      students_list.shift if @options[:ignore_first_line]

      ## GET COORDINATOR LIST, for later processing
      coordinator_list = User.active.coordinators.collect { |u| u.id }
      ## ENSURE first id in the list is not the most recent assigned coordinator
      # if Student.most_recent_students(1).size > 0
      #   last_assigned_coordinator_id = Student.most_recent_students(1).first.details.transcription_coordinator_id
      #   if last_assigned_coordinator_id == coordinator_list.last
      #     id = coordinator_list.pop
      #     coordinator_list.insert(0, id)
      #   end
      # end

      status = { updated: [], created: [], errors: [] }

      students_list.each do |student_array|

        params = Student.build_hash_from_array(student_array, @options[:fields_order])
        student = Student.where("student_details.student_number = ?", params[:student_details_attributes][:student_number]).references(:student_details).includes(:student_details).first
{'fraction_non_alphanumeric': 0.09227129337539432, 'fraction_numerical': 0.0031545741324921135, 'mean_word_length': 2.890593047034765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2108771', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1114, 'n_words': 217}