Class: Import
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Import
- Defined in:
- app/models/import.rb
Instance Method Summary collapse
- #new_source_data_exists? ⇒ Boolean
- #remove_listings_not_present(fresh_listing_keys) ⇒ Object
- #set_import_format ⇒ Object
- #source_url_last_modified ⇒ Object
Instance Method Details
#new_source_data_exists? ⇒ Boolean
33 34 35 |
# File 'app/models/import.rb', line 33 def new_source_data_exists? self.source_data_modified.eql? self.source_url_last_modified ? false : true end |
#remove_listings_not_present(fresh_listing_keys) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/models/import.rb', line 13 def remove_listings_not_present fresh_listing_keys existing_listing_keys = self.listings.all.pluck(:listing_key) stale_listing_keys = existing_listing_keys.delete_if{|key| fresh_listing_keys.include? key } stale_listing_keys.each do |listing_key| Listing.find_by(listing_key: listing_key).destroy end stale_listing_keys end |
#set_import_format ⇒ Object
22 23 24 |
# File 'app/models/import.rb', line 22 def set_import_format self.import_format = ImportFormat.find_by(name: 'reso') unless self.import_format.present? end |
#source_url_last_modified ⇒ Object
26 27 28 29 30 31 |
# File 'app/models/import.rb', line 26 def source_url_last_modified open(self.source_url, http_basic_authentication: [self.source_user, self.source_pass], allow_redirections: :all ){|f| return f.last_modified } end |