caboose-rets 0.0.70 → 0.0.71
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 +8 -8
- data/app/models/caboose_rets/rets_importer.rb +16 -28
- data/lib/caboose_rets/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NTc1MzEzZTk0Yjk3NGFlY2UyMWJhMTk5NmExNWI0ZDI1YWE5NmVlZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGQyNDczYjQyNThjMzM2NDAzM2QzNDZhNTI3MDY2NTAxNmExYTJjMw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzhjY2Y1YWMxYzg1YWIyNzNiZGI0ZWM2OWZiY2ExNDFjNzJkYjZlMzM0OTJi
|
10
|
+
N2RlNzcxZjhmNjQ1YWFjOWJiY2NlNjQ2OGI5YWIyZWI4MjMyZGZhMTliYTQy
|
11
|
+
NzliNmIxYTUxYjI1OGYxNjU1ODllNzdkZDcxNTgwMTMxNTUzMjg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2Q4YWMzODc5YjY1YzlkZmUxOWU5OTYxNjVmZjNlN2NlYWU4ODQzMDVmODky
|
14
|
+
NWZkZTVkOTE5NGNhYjI1ZjM5MTg0MDRjNGVjMDQzYzJlYjY3YzYwYTcwYmY2
|
15
|
+
ZWY5MmUzZjhlNjdkZWY5M2UzMDE0MmRkNjA2Mjk1OTA2ZGU0YTE=
|
@@ -254,7 +254,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
254
254
|
end
|
255
255
|
|
256
256
|
# Delete any records in the local database that shouldn't be there
|
257
|
-
|
257
|
+
self.log("- Deleting GFX records for MLS ##{p.mls_acct} in the local database that are not in the remote database...")
|
258
258
|
query = "select media_id from rets_media where mls_acct = '#{p.mls_acct}'"
|
259
259
|
rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
260
260
|
local_ids = rows.collect{ |row| row['media_id'] }
|
@@ -336,10 +336,10 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
336
336
|
def self.purge_helper(class_type, date_modified)
|
337
337
|
m = self.meta(class_type)
|
338
338
|
|
339
|
-
|
339
|
+
self.log("Purging #{class_type}...")
|
340
340
|
|
341
341
|
# Get the total number of records
|
342
|
-
|
342
|
+
self.log("- Getting total number of records for #{class_type}...")
|
343
343
|
params = {
|
344
344
|
:search_type => m.search_type,
|
345
345
|
:class => class_type,
|
@@ -354,43 +354,34 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
354
354
|
ids = []
|
355
355
|
k = m.remote_key_field
|
356
356
|
(0...batch_count).each do |i|
|
357
|
-
|
358
|
-
self.client.search(params.merge({ :select => [k], :limit => 5000, :offset => 5000*i })) do |data|
|
359
|
-
ids <<
|
360
|
-
|
361
|
-
|
362
|
-
when 'LND' then data[k]
|
363
|
-
when 'MUL' then data[k]
|
364
|
-
when 'OFF' then data[k]
|
365
|
-
when 'AGT' then data[k]
|
366
|
-
when 'OPH' then data[k].to_i
|
367
|
-
when 'GFX' then data[k]
|
368
|
-
end
|
369
|
-
end
|
370
|
-
end
|
357
|
+
self.log("- Getting ids for #{class_type} (batch #{i+1} of #{batch_count})...")
|
358
|
+
self.client.search(params.merge({ :select => [k], :limit => 5000, :offset => 5000*i })) do |data|
|
359
|
+
ids << (class_type == 'OPH' ? data[k].to_i : data[k])
|
360
|
+
end
|
361
|
+
end
|
371
362
|
|
372
363
|
# Delete any records in the local database that shouldn't be there
|
373
|
-
|
364
|
+
self.log("- Finding #{class_type} records in the local database that are not in the remote database...")
|
374
365
|
t = m.local_table
|
375
366
|
k = m.local_key_field
|
376
367
|
query = "select distinct #{k} from #{t}"
|
377
368
|
rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
378
369
|
local_ids = rows.collect{ |row| row[k] }
|
379
370
|
ids_to_remove = local_ids - ids
|
380
|
-
|
381
|
-
|
371
|
+
self.log("- Found #{ids_to_remove.count} #{class_type} records in the local database that are not in the remote database.")
|
372
|
+
self.log("- Deleting #{class_type} records in the local database that shouldn't be there...")
|
382
373
|
query = ["delete from #{t} where #{k} not in (?)", ids_to_remove]
|
383
374
|
ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
384
375
|
|
385
376
|
# Find any ids in the remote database that should be in the local database
|
386
|
-
|
377
|
+
self.log("- Finding #{class_type} records in the remote database that should be in the local database...")
|
387
378
|
query = "select distinct #{k} from #{t}"
|
388
379
|
rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
389
380
|
local_ids = rows.collect{ |row| row[k] }
|
390
381
|
ids_to_add = ids - local_ids
|
391
|
-
|
382
|
+
self.log("- Found #{ids_to_add.count} #{class_type} records in the remote database that we need to add to the local database.")
|
392
383
|
ids_to_add.each do |id|
|
393
|
-
|
384
|
+
self.log("- Importing #{id}...")
|
394
385
|
case class_type
|
395
386
|
when 'RES' then self.delay.import_residential_property(id, false)
|
396
387
|
when 'COM' then self.delay.import_commercial_property(id, false)
|
@@ -449,7 +440,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
449
440
|
local_ids = rows.collect{ |row| row[k] }
|
450
441
|
ids_to_add = ids - local_ids
|
451
442
|
ids_to_add.each do |id|
|
452
|
-
|
443
|
+
self.log("Importing #{id}...")
|
453
444
|
case class_type
|
454
445
|
when 'RES' then self.delay.import_residential_property(id, false)
|
455
446
|
when 'COM' then self.delay.import_commercial_property(id, false)
|
@@ -482,10 +473,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
482
473
|
task_started = self.lock_task
|
483
474
|
|
484
475
|
begin
|
485
|
-
overlap = 30.seconds
|
486
|
-
puts DateTime.now
|
487
|
-
puts self.last_purged
|
488
|
-
puts (DateTime.now - self.last_purged)
|
476
|
+
overlap = 30.seconds
|
489
477
|
if (DateTime.now - self.last_purged).to_i > 1
|
490
478
|
self.purge
|
491
479
|
self.save_last_purged(task_started)
|
data/lib/caboose_rets/version.rb
CHANGED