caboose-rets 0.0.82 → 0.0.83

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzU1NmMzNjhjOTY3ZTdlMjJkMWEwMzE2MzhiZmM4MjZjZmZjOTk1Ng==
4
+ MzY3YmVlYjQ5ZDAzY2QzMDljZTg4ODBkMGU0YTZiYjUwMzNkYTNlOA==
5
5
  data.tar.gz: !binary |-
6
- NjU4NThlYTRjMWIwOTBkYzk1MzkwNmY2NjI5MDMxODY5MWFkZDYxZg==
6
+ NmMzNTc5Mzc0MjkyODI4MWFmYjg3MzIxNWIzMmMxMzVmMDE4NDM5OA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWRhZjAwZTgwYTRiMDdlNmFlNDYwM2Y3N2MwZjhlM2UxN2E2ZTM4MjlkNzdk
10
- MmRiZDk0YzNiM2U2Mzk4YWNlMmYwNTBhN2ZmYmQ0ZDNmOTBmNDkzNDE0ZGE1
11
- NTMyY2Q1ZDAyMWQxNjI0NjdlOGRjNmNlODU2OGNiMzA4Mjg1NzE=
9
+ OGY3MjI4NDJmYzg5ZDBkZjQxMWVlNmVmYjI3M2MyNWZhNjkyYjFiMzkxYTA5
10
+ YjMwN2YwOWJhN2I0MGEzYTAwNzVhMGNkMTIwOTA4ZGVlZTc3YTVhZmQ3OGZl
11
+ NmEzNTg2YWE0NjAzNzc3NTU3ZTE5OGU5MWEwODI5Zjg1ZWQyYjA=
12
12
  data.tar.gz: !binary |-
13
- ZDcxNzJhMDE1NjgwZjdlOTMxZjA0ZjY3NTQ5ODkzYmNiOGUwYTg0MmQzNDdl
14
- ODBiNGE4M2VjMzQ5MDBkNTQyMjIyYTE3NzEyMDM2YTNjN2E1NWZiNGU2NGYy
15
- MWNkODdjMWZmMTY0NTFhYjI2NDA5ZWIwOGJmZWQ5ZjVmMjI3NzE=
13
+ YzI0YjZkY2YzYmI2OWY4ODZkMTZiNTBlZDM5NmY3MzRmNmZhODQwM2RjNjQ1
14
+ NjJiMDQ4M2RiY2VmNWEyZjY3ZDAyNDkzNGE2MjM2MjEwNmNkMmI4MDkwMjll
15
+ Y2E2N2JiYmEzMDUxMTg5YmMyZjc2ODQzZTM3ODJjN2NhNzgxMzA=
@@ -254,15 +254,17 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
254
254
  m.save
255
255
  end
256
256
 
257
- # Delete any records in the local database that shouldn't be there
258
- self.log("- Deleting GFX records for MLS ##{p.mls_acct} in the local database that are not in the remote database...")
259
- query = "select media_id from rets_media where mls_acct = '#{p.mls_acct}'"
260
- rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
261
- local_ids = rows.collect{ |row| row['media_id'] }
262
- ids_to_remove = local_ids - ids
263
- if ids_to_remove && ids_to_remove.count > 0
264
- query = ["delete from rets_media where media_id not in (?)", ids_to_remove]
265
- ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
257
+ if ids.count > 0
258
+ # Delete any records in the local database that shouldn't be there
259
+ self.log("- Deleting GFX records for MLS ##{p.mls_acct} in the local database that are not in the remote database...")
260
+ query = "select media_id from rets_media where mls_acct = '#{p.mls_acct}'"
261
+ rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
262
+ local_ids = rows.collect{ |row| row['media_id'] }
263
+ ids_to_remove = local_ids - ids
264
+ if ids_to_remove && ids_to_remove.count > 0
265
+ query = ["delete from rets_media where media_id not in (?)", ids_to_remove]
266
+ ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
267
+ end
266
268
  end
267
269
 
268
270
  end
@@ -448,28 +450,30 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
448
450
  end
449
451
  end
450
452
 
451
- # Delete any records in the local database that shouldn't be there
452
- t = m.local_table
453
- k = m.local_key_field
454
- query = ["delete from #{t} where #{k} not in (?)", ids]
455
- ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
456
-
457
- # Find any ids in the remote database that should be in the local database
458
- query = "select distinct #{k} from #{t}"
459
- rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
460
- local_ids = rows.collect{ |row| row[k] }
461
- ids_to_add = ids - local_ids
462
- ids_to_add.each do |id|
463
- self.log("Importing #{id}...")
464
- case class_type
465
- when 'RES' then self.delay.import_residential_property(id, false)
466
- when 'COM' then self.delay.import_commercial_property(id, false)
467
- when 'LND' then self.delay.import_land_property(id, false)
468
- when 'MUL' then self.delay.import_multi_family_property(id, false)
469
- when 'OFF' then self.delay.import_office(id, false)
470
- when 'AGT' then self.delay.import_agent(id, false)
471
- when 'OPH' then self.delay.import_open_house(id, false)
472
- when 'GFX' then self.delay.import_media(id)
453
+ if ids.count > 0
454
+ # Delete any records in the local database that shouldn't be there
455
+ t = m.local_table
456
+ k = m.local_key_field
457
+ query = ["delete from #{t} where #{k} not in (?)", ids]
458
+ ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
459
+
460
+ # Find any ids in the remote database that should be in the local database
461
+ query = "select distinct #{k} from #{t}"
462
+ rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
463
+ local_ids = rows.collect{ |row| row[k] }
464
+ ids_to_add = ids - local_ids
465
+ ids_to_add.each do |id|
466
+ self.log("Importing #{id}...")
467
+ case class_type
468
+ when 'RES' then self.delay.import_residential_property(id, false)
469
+ when 'COM' then self.delay.import_commercial_property(id, false)
470
+ when 'LND' then self.delay.import_land_property(id, false)
471
+ when 'MUL' then self.delay.import_multi_family_property(id, false)
472
+ when 'OFF' then self.delay.import_office(id, false)
473
+ when 'AGT' then self.delay.import_agent(id, false)
474
+ when 'OPH' then self.delay.import_open_house(id, false)
475
+ when 'GFX' then self.delay.import_media(id)
476
+ end
473
477
  end
474
478
  end
475
479
 
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.0.82'
2
+ VERSION = '0.0.83'
3
3
  end
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.0.82
4
+ version: 0.0.83
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-16 00:00:00.000000000 Z
11
+ date: 2014-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caboose-cms