caboose-rets 0.1.75 → 0.1.76
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/caboose_rets/rets_importer.rb +28 -9
- data/lib/caboose_rets/version.rb +1 -1
- data/lib/tasks/caboose_rets.rake +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c392810ba009e1d20f95ab19de9e16a2b72b3f59d0377527e861ef693cfab0aa
|
4
|
+
data.tar.gz: b26b29781e8f5f781f611c0eea5f7e40c13b39175170c38406101b2e951104b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a3edf4f57a58eae518b881f8e2cd37992d6b2b5120e9aced1c94b9acb05907be934f49ff8c131285dc6548392a73c02ef5c9e4adb8748d67f2859a64ef455d9
|
7
|
+
data.tar.gz: 7cc49ef7f33043c324d95d386733f0cdf75f07900eed9cfb24eec04ee140c14ee1a63a58c8aecdca029c9e761f873c3004a56adb606a3560b7223aefbdb6a7fc
|
@@ -119,7 +119,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
119
119
|
|
120
120
|
def self.update_after(date_modified, save_images = true)
|
121
121
|
si = save_images ? 'saving images' : 'not saving images'
|
122
|
-
self.log3(nil,nil,"Updating after #{date_modified} and #{si}")
|
122
|
+
self.log3(nil,nil,"Updating everything after #{date_modified} and #{si}")
|
123
123
|
self.delay(:priority => 10, :queue => 'rets').update_helper('Property' , date_modified, save_images)
|
124
124
|
self.delay(:priority => 10, :queue => 'rets').update_helper('Office' , date_modified, false)
|
125
125
|
self.delay(:priority => 10, :queue => 'rets').update_helper('Member' , date_modified, false)
|
@@ -127,15 +127,12 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def self.update_helper(class_type, date_modified, save_images = true)
|
130
|
-
|
131
|
-
self.log3(class_type,nil,"Updating
|
130
|
+
si = save_images ? 'saving images' : 'not saving images'
|
131
|
+
self.log3(class_type,nil,"Updating #{class_type} modified after #{date_modified} and #{si}")
|
132
132
|
m = self.meta(class_type)
|
133
133
|
k = m.remote_key_field
|
134
134
|
d = date_modified.in_time_zone(CabooseRets::timezone).strftime("%FT%T")
|
135
|
-
|
136
135
|
quer = "(#{m.date_modified_field}=#{d}+)"
|
137
|
-
quer += "OR(PhotosChangeTimestamp=#{d}+)" if class_type == 'Property'
|
138
|
-
|
139
136
|
params = {
|
140
137
|
:search_type => m.search_type,
|
141
138
|
:class => class_type,
|
@@ -155,8 +152,30 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
155
152
|
when 'OpenHouse' then self.delay(:priority => 10, :queue => 'rets').import_open_house(data[k], false)
|
156
153
|
end
|
157
154
|
end
|
155
|
+
|
156
|
+
# Check for changed images
|
157
|
+
if class_type == 'Property'
|
158
|
+
self.log3("Property",nil,"Checking for modified images on Properties...")
|
159
|
+
d1 = (self.last_updated - 1.hours).in_time_zone(CabooseRets::timezone).strftime("%FT%T")
|
160
|
+
params = {
|
161
|
+
:search_type => m.search_type,
|
162
|
+
:class => class_type,
|
163
|
+
:select => [m.remote_key_field],
|
164
|
+
:querytype => 'DMQL2',
|
165
|
+
:query => "(PhotosChangeTimestamp=#{d1}+)",
|
166
|
+
:standard_names_only => true,
|
167
|
+
:timeout => -1
|
168
|
+
}
|
169
|
+
self.log3(class_type,nil,"Searching with params: " + params.to_s)
|
170
|
+
self.client.search(params) do |data|
|
171
|
+
self.log3(class_type,nil,"Resulting data: " + data.to_s)
|
172
|
+
self.delay(:priority => 10, :queue => 'rets').import_properties(data[k], true)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
158
176
|
end
|
159
177
|
|
178
|
+
|
160
179
|
#=============================================================================
|
161
180
|
# Single model import methods (called from a worker dyno)
|
162
181
|
#=============================================================================
|
@@ -431,7 +450,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
431
450
|
(0...batch_count).each do |i|
|
432
451
|
self.log3(class_type,nil,"Getting ids for #{class_type} (batch #{i+1} of #{batch_count})...")
|
433
452
|
self.client.search(params.merge({ :select => [k], :limit => 5000, :offset => 5000*i })) do |data|
|
434
|
-
ids <<
|
453
|
+
ids << data[k]
|
435
454
|
end
|
436
455
|
end
|
437
456
|
|
@@ -455,7 +474,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
455
474
|
ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
456
475
|
|
457
476
|
# Find any ids in the remote database that should be in the local database
|
458
|
-
self.log3(class_type,nil,"
|
477
|
+
self.log3(class_type,nil,"Finding #{class_type} records in the remote database that should be in the local database...")
|
459
478
|
query = "select distinct #{k} from #{t}"
|
460
479
|
rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
461
480
|
local_ids = rows.collect{ |row| row[k] }
|
@@ -567,7 +586,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
567
586
|
self.save_last_purged(task_started)
|
568
587
|
overlap = 1.week
|
569
588
|
end
|
570
|
-
self.update_after(self.last_updated - overlap)
|
589
|
+
self.update_after((self.last_updated - overlap), false)
|
571
590
|
self.download_missing_images
|
572
591
|
self.log3(nil,nil,"Saving the timestamp for when we updated to #{task_started.to_s}...")
|
573
592
|
self.save_last_updated(task_started)
|
data/lib/caboose_rets/version.rb
CHANGED
data/lib/tasks/caboose_rets.rake
CHANGED
@@ -130,6 +130,14 @@ namespace :caboose_rets do
|
|
130
130
|
CabooseRets::RetsImporter.download_missing_images
|
131
131
|
end
|
132
132
|
|
133
|
+
desc "Re-import property details"
|
134
|
+
task :reimport_properties => :environment do
|
135
|
+
props = CabooseRets::Property.all
|
136
|
+
props.each do |p|
|
137
|
+
CabooseRets::RetsImporter.delay(:queue => 'rets', :priority => 4).import_properties(p.mls_number, false)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
133
141
|
desc "Reimports Property Images"
|
134
142
|
task :reimport_property_images => :environment do
|
135
143
|
props = CabooseRets::Property.all
|