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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTJmMGYzMzY4ZmQ4YzIyNjFhOGJiODQxM2JkZGNmZWY0YWYwYTE5Zg==
4
+ YTQyZjRjMDY3NzlhMjAzYmJjMGEwOTI5OTY3MWQzMGM2YmEyYzU0ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZGFhNmMxM2U4ODg0ZjZlMzQwMTcxMzg5ZjViMmE3MDMxNGFjYzA4OA==
6
+ Yzg3ZWYxMzk0YjY1ZjJlNmIwMDg4NjcyMzkwNGI2NTZhMjk1ODk4Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZDgzYTZmZjcxNzdhYWExMDYwY2NmYWM5OGJiMzU4YjJhMmI0ZGIzZjQ2M2I1
10
- MjgyNGQxNGVlOGU2M2I3YmQ4NTczNTllMWM1NTMyM2I3NjA0N2UyOTRiMGJh
11
- MTRiMmZhNmJkZDE3ZWQ0MmU0NmRmZTNiMGIxZWQ5ZDIxMmVmMGQ=
9
+ ZGFlYzcwYzYyMjg2NWVhYWVmODhmM2RlODdlNTczMDc5MGU3ODEzYTFlYWY1
10
+ M2NlNmNjNDNiMTRmZmU3Y2EyYmJjNmQ2NjhiMmI5NjhhMmJlMzdiNjQ1NjMx
11
+ OTE1ZTVmMzZhODhmMGY1NmQ2MjNlMjk5YTMxZWNlYjc4ZmJjNjM=
12
12
  data.tar.gz: !binary |-
13
- NzcxNGExNzE4M2NlN2IyNmM3OTMwNzMwNDI5M2NkOWEwNWE1M2ZmNDdkMGY2
14
- NWQxNjZhNDJmNTU2ZGI4OGIyYmVjMDE1OWY5NDBkZWJlMmQzMmNhM2ZlZmJk
15
- MmE3YzE0NDdiYzliYTU4NTIwMGY3ZGIzOWE2ZTk0MTFiNTUwZjk=
13
+ Y2M1OGJlYWFhZmQ1NDk4YmJhNDg5ZjA1NDUwMDQ2MTAwNDgwYzYzNjU3Njhj
14
+ NWUxN2RmZDA4OTU0MWFjMWM1NTlhYWIxMzU4ZjU4NWQyM2EzYTJkMGQwMTlm
15
+ MzY3YzNjN2IyODQ2NDQwMDBkMmY1ZDUyMGJiZjBlZDA3OTlhMmE=
@@ -373,38 +373,43 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
373
373
  end
374
374
  end
375
375
 
376
- # Delete any records in the local database that shouldn't be there
377
- self.log("- Finding #{class_type} records in the local database that are not in the remote database...")
378
- t = m.local_table
379
- k = m.local_key_field
380
- query = "select distinct #{k} from #{t}"
381
- rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
382
- local_ids = rows.collect{ |row| row[k] }
383
- ids_to_remove = local_ids - ids
384
- self.log("- Found #{ids_to_remove.count} #{class_type} records in the local database that are not in the remote database.")
385
- self.log("- Deleting #{class_type} records in the local database that shouldn't be there...")
386
- query = ["delete from #{t} where #{k} not in (?)", ids_to_remove]
387
- ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
388
-
389
- # Find any ids in the remote database that should be in the local database
390
- self.log("- Finding #{class_type} records in the remote database that should be in the local database...")
391
- query = "select distinct #{k} from #{t}"
392
- rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
393
- local_ids = rows.collect{ |row| row[k] }
394
- ids_to_add = ids - local_ids
395
- self.log("- Found #{ids_to_add.count} #{class_type} records in the remote database that we need to add to the local database.")
396
- ids_to_add.each do |id|
397
- self.log("- Importing #{id}...")
398
- case class_type
399
- when 'RES' then self.delay.import_residential_property(id, false)
400
- when 'COM' then self.delay.import_commercial_property(id, false)
401
- when 'LND' then self.delay.import_land_property(id, false)
402
- when 'MUL' then self.delay.import_multi_family_property(id, false)
403
- when 'OFF' then self.delay.import_office(id, false)
404
- when 'AGT' then self.delay.import_agent(id, false)
405
- when 'OPH' then self.delay.import_open_house(id, false)
406
- when 'GFX' then self.delay.import_media(id, false)
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
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.0.77'
2
+ VERSION = '0.0.78'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-rets
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.77
4
+ version: 0.0.78
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry