app/importers/file_importers/educators_importer.rb
# Match existing Homeroom and update reference to Educator.
Match existing Homeroom and update reference to Educator.
Match existing Homeroom and update reference to Educator .
def match_homeroom(row, maybe_educator)
    if PerDistrict.new.is_nil_homeroom_name?(row[:homeroom])
      @ignored_special_nil_homeroom_count += 1
      return nil
    end
    if !row[:homeroom]
      @ignored_no_homeroom_count += 1
      return nil
    end
    school_id = school_ids_dictionary[row[:school_local_id]]
    if school_id.nil?
      @ignored_homeroom_because_no_school_count += 1
      return nil
    end
    homeroom = Homeroom.find_or_initialize_by({
      name: row[:homeroom],
      school_id: school_id
    })
    educator_id = maybe_educator.try(:id) 
    homeroom.assign_attributes(educator_id: educator_id)
    homeroom
  end
def match_homeroom ( row , maybe_educator ) if PerDistrict . new . is_nil_homeroom_name? ( row [ :homeroom ] ) @ignored_special_nil_homeroom_count += 1 return nil end if ! row [ :homeroom ] @ignored_no_homeroom_count += 1 return nil end school_id = school_ids_dictionary [ row [ :school_local_id ] ] if school_id . nil? @ignored_homeroom_because_no_school_count += 1 return nil end homeroom = Homeroom . find_or_initialize_by ( { name : row [ :homeroom ] , school_id : school_id } ) educator_id = maybe_educator . try ( :id ) homeroom . assign_attributes ( educator_id : educator_id ) homeroom end
Match existing Homeroom and update reference to Educator.
Match existing Homeroom and update reference to Educator .
# Special case for NB magic "nil" value # No homeroom for educator # If no school, can't do match # Match Homeroom (guaranteed to be uniqe on {name, school} by database index) # Update to reference educator # might be nil
row
<not_specific>
maybe_educator
<not_specific>