app/models/import.rb in reso-0.1.4.4 vs app/models/import.rb in reso-0.1.4.5

- old
+ new

@@ -45,11 +45,11 @@ if self.new_source_data_exists? self.update_attribute(:status, :running) source_data_modified = self.source_url_last_modified - l, count, found_listing_keys, stream = 0, 0, [], '' + l, count, found_listing_keys, snapshots, stream = 0, 0, [], [], '' open_tag, close_tag = get_open_and_closing_tag_for self.repeating_element # Grab a file to work with filepath = download_feed_to_import self filepath = uncompress_and_return_new_filepath(filepath) if filepath.split('.').last.downcase == 'gz' @@ -64,10 +64,14 @@ while (from_here = stream.index(open_tag)) && (to_there = stream.index(close_tag)) xml = stream[from_here..to_there + (close_tag.length-1)] doc = Nokogiri::XML([xml_header, xml].join).remove_namespaces! found_listing_keys << create_queued_listing_and_return_listing_key(doc, self) stream.gsub!(xml, '') + if ((l += 1) % 100).zero? + GC.start + snapshots << [l, ] l/(Time.now - start_time) + end end end end_time = Time.now removed_listing_keys = self.remove_listings_not_present(found_listing_keys) self.assign_attributes({ @@ -85,10 +89,10 @@ end end end def download_feed_to_import import - filename = import.source_url.split('/').last + filename = [Time.now.to_s.parameterize, import.source_url.split('/').last].join filepath = Rails.root.join('tmp', filename).to_s File.delete(filepath) if File.file? filepath open(filepath, 'wb') do |file| file << open(import.source_url, http_basic_authentication: [import.source_user, import.source_pass],