caboose-rets 0.0.77 → 0.0.78
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/models/caboose_rets/rets_importer.rb +36 -31
- 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
|
+
YTQyZjRjMDY3NzlhMjAzYmJjMGEwOTI5OTY3MWQzMGM2YmEyYzU0ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Yzg3ZWYxMzk0YjY1ZjJlNmIwMDg4NjcyMzkwNGI2NTZhMjk1ODk4Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZGFlYzcwYzYyMjg2NWVhYWVmODhmM2RlODdlNTczMDc5MGU3ODEzYTFlYWY1
|
10
|
+
M2NlNmNjNDNiMTRmZmU3Y2EyYmJjNmQ2NjhiMmI5NjhhMmJlMzdiNjQ1NjMx
|
11
|
+
OTE1ZTVmMzZhODhmMGY1NmQ2MjNlMjk5YTMxZWNlYjc4ZmJjNjM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Y2M1OGJlYWFhZmQ1NDk4YmJhNDg5ZjA1NDUwMDQ2MTAwNDgwYzYzNjU3Njhj
|
14
|
+
NWUxN2RmZDA4OTU0MWFjMWM1NTlhYWIxMzU4ZjU4NWQyM2EzYTJkMGQwMTlm
|
15
|
+
MzY3YzNjN2IyODQ2NDQwMDBkMmY1ZDUyMGJiZjBlZDA3OTlhMmE=
|
@@ -373,38 +373,43 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
|
|
373
373
|
end
|
374
374
|
end
|
375
375
|
|
376
|
-
#
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
376
|
+
# Only do stuff if we got a real response from the server
|
377
|
+
if ids.count > 0
|
378
|
+
|
379
|
+
# Delete any records in the local database that shouldn't be there
|
380
|
+
self.log("- Finding #{class_type} records in the local database that are not in the remote database...")
|
381
|
+
t = m.local_table
|
382
|
+
k = m.local_key_field
|
383
|
+
query = "select distinct #{k} from #{t}"
|
384
|
+
rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
385
|
+
local_ids = rows.collect{ |row| row[k] }
|
386
|
+
ids_to_remove = local_ids - ids
|
387
|
+
self.log("- Found #{ids_to_remove.count} #{class_type} records in the local database that are not in the remote database.")
|
388
|
+
self.log("- Deleting #{class_type} records in the local database that shouldn't be there...")
|
389
|
+
query = ["delete from #{t} where #{k} not in (?)", ids_to_remove]
|
390
|
+
ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
391
|
+
|
392
|
+
# Find any ids in the remote database that should be in the local database
|
393
|
+
self.log("- Finding #{class_type} records in the remote database that should be in the local database...")
|
394
|
+
query = "select distinct #{k} from #{t}"
|
395
|
+
rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
396
|
+
local_ids = rows.collect{ |row| row[k] }
|
397
|
+
ids_to_add = ids - local_ids
|
398
|
+
self.log("- Found #{ids_to_add.count} #{class_type} records in the remote database that we need to add to the local database.")
|
399
|
+
ids_to_add.each do |id|
|
400
|
+
self.log("- Importing #{id}...")
|
401
|
+
case class_type
|
402
|
+
when 'RES' then self.delay.import_residential_property(id, false)
|
403
|
+
when 'COM' then self.delay.import_commercial_property(id, false)
|
404
|
+
when 'LND' then self.delay.import_land_property(id, false)
|
405
|
+
when 'MUL' then self.delay.import_multi_family_property(id, false)
|
406
|
+
when 'OFF' then self.delay.import_office(id, false)
|
407
|
+
when 'AGT' then self.delay.import_agent(id, false)
|
408
|
+
when 'OPH' then self.delay.import_open_house(id, false)
|
409
|
+
when 'GFX' then self.delay.import_media(id, false)
|
410
|
+
end
|
407
411
|
end
|
412
|
+
|
408
413
|
end
|
409
414
|
|
410
415
|
end
|
data/lib/caboose_rets/version.rb
CHANGED