caboose-rets 0.1.115 → 0.1.116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/caboose_rets/property.rb +6 -10
- data/app/models/caboose_rets/rets_importer.rb +21 -2
- data/lib/caboose_rets/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f294090601dfd6564470df919281b86bf4f8070397256128a3732fb7bb0cd1d2
|
4
|
+
data.tar.gz: 9dc49dec8f68574d9cd04249df03c51203b6b30bc7e0266cfb249e058c6d9b5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d99faf2eacf150c0f43b833dfc673e1eecb3c5a98ca3a55541dd123bc183c31c443093c8c31db6eae807ea62ebd7fa42f67702fcda38700f2c44823827bbf6b2
|
7
|
+
data.tar.gz: 60dbf8a0fc5787eaa61eec63b1bb946253b1dbca44404233b3e7461fe88f47b74a025ff04924177a6c7ac8b159fca4986f26487af086ebd99453185e50e358a4
|
@@ -110,16 +110,12 @@ class CabooseRets::Property <ActiveRecord::Base
|
|
110
110
|
# self.income_rental = data['GrossIncome']
|
111
111
|
self.interior_features = data['InteriorFeatures']
|
112
112
|
self.land_features_extras = data['LotFeatures']
|
113
|
-
|
114
|
-
self.
|
115
|
-
self.longitude
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
end
|
120
|
-
self.latitude = nil if self.latitude == 0.0
|
121
|
-
self.longitude = nil if self.longitude == 0.0
|
122
|
-
# self.landscaping = data['Landscaping']
|
113
|
+
self.latitude = self.latitude.blank? ? nil : self.latitude
|
114
|
+
self.longitude = self.longitude.blank? ? nil : self.longitude
|
115
|
+
if self.latitude == 0.0 || self.latitude == '0.0' || self.longitude == 0.0 || self.longitude == '0.0' || (self.street_number != data['StreetNumber']) || (self.street_name != data['StreetName']) || (self.city != data['City']) || (self.postal_code != data['PostalCode'])
|
116
|
+
self.latitude = nil
|
117
|
+
self.longitude = nil
|
118
|
+
end
|
123
119
|
self.laundry = data['LaundryFeatures']
|
124
120
|
self.legal_description = data['TaxLegalDescription']
|
125
121
|
self.legal_lot = data['TaxLot']
|
@@ -210,7 +210,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
210
210
|
p = CabooseRets::Property.where(:mls_number => mls_id.to_s).first
|
211
211
|
if p != nil && p.status == 'Active'
|
212
212
|
self.download_property_images(p) if save_images == true
|
213
|
-
if
|
213
|
+
if p.latitude.blank? || p.latitude == '0.0' || p.longitude.blank? || p.longitude == '0.0'
|
214
214
|
self.update_coords(p)
|
215
215
|
end
|
216
216
|
else
|
@@ -284,13 +284,16 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
284
284
|
|
285
285
|
def self.download_property_images(p)
|
286
286
|
self.log3('Property',p.mls_number,"Downloading images for #{p.mls_number}...")
|
287
|
+
ids_to_keep = []
|
287
288
|
begin
|
288
289
|
self.client.get_object(:resource => 'Property', :type => 'Photo', :location => false, :id => "#{p.matrix_unique_id}:*") do |headers, content|
|
289
290
|
next if headers.blank?
|
290
291
|
ind = headers['orderhint'] ? headers['orderhint'].to_i : 0
|
291
292
|
self.log3('Media',p.mls_number,headers.to_s)
|
292
293
|
self.log3('Media',p.mls_number,"Downloading photo with content-id #{headers['content-id']}, index #{ind}")
|
294
|
+
is_new = false
|
293
295
|
m = CabooseRets::Media.where(:media_mui => headers['content-id'], :media_order => ind).first
|
296
|
+
is_new = true if m.nil?
|
294
297
|
m = CabooseRets::Media.new if m.nil?
|
295
298
|
tmp_path = "#{Rails.root}/tmp/rets_media_#{headers['content-id']}_#{ind}.jpeg"
|
296
299
|
File.open(tmp_path, "wb") do |f|
|
@@ -310,7 +313,12 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
310
313
|
if cm && !cm.id.blank?
|
311
314
|
m.media_id = cm.id
|
312
315
|
m.save
|
313
|
-
|
316
|
+
ids_to_keep << m.id
|
317
|
+
if is_new
|
318
|
+
self.log3("Media",p.mls_number,"Created new RetsMedia object #{m.id}, media_id = #{m.media_id}")
|
319
|
+
else
|
320
|
+
self.log3("Media",p.mls_number,"RetsMedia object already existed #{m.id}, updated media_id = #{m.media_id}")
|
321
|
+
end
|
314
322
|
self.log3("Media",p.mls_number,"Image rets_media_#{headers['content-id']}_#{ind} saved")
|
315
323
|
else
|
316
324
|
self.log3("Media",p.mls_number,"CabooseMedia was not created for some reason, not saving RetsMedia")
|
@@ -324,6 +332,17 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
324
332
|
self.log3("Media",p.mls_number,"Error downloading images for property with MLS # #{p.mls_number}")
|
325
333
|
end
|
326
334
|
|
335
|
+
# If we downloaded new images, look for old images to delete
|
336
|
+
if ids_to_keep.count > 0
|
337
|
+
self.log3("Media",p.mls_number,"Keeping new RetsMedia ids: #{ids_to_keep}")
|
338
|
+
self.log3("Media",p.mls_number,"Looking for old RetsMedia to delete")
|
339
|
+
CabooseRets::Media.where(:media_mui => p.matrix_unique_id).where("id not in (?)",ids_to_keep).each do |med|
|
340
|
+
self.log3("Media",p.mls_number,"Deleting old RetsMedia #{med.id} and CabooseMedia #{med.media_id}...")
|
341
|
+
m = Caboose::Media.where(:id => med.media_id).where("name ILIKE ?","rets_media%").first
|
342
|
+
m.destroy if m
|
343
|
+
med.destroy
|
344
|
+
end
|
345
|
+
end
|
327
346
|
|
328
347
|
# # Get first image
|
329
348
|
# self.client.get_object(:resource => 'Property', :type => 'Photo', :location=> false, :id => "#{p.matrix_unique_id}:0") do |headers, content|
|
data/lib/caboose_rets/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-rets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.116
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caboose-cms
|