caboose-rets 0.0.70 → 0.0.71

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
- MWExNTE4ZTRhZDM1MDUxY2YwNzllZTA4ZjgxMTJhZjNmNjQ2ZDdhNg==
4
+ NTc1MzEzZTk0Yjk3NGFlY2UyMWJhMTk5NmExNWI0ZDI1YWE5NmVlZA==
5
5
  data.tar.gz: !binary |-
6
- ZmM4YmY1MWM3MWUxOGExMjY2M2NhYmVlYzA1MWRhOWVmMWE1ZTY2OA==
6
+ OGQyNDczYjQyNThjMzM2NDAzM2QzNDZhNTI3MDY2NTAxNmExYTJjMw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjcwNzQyZjkwMjg5NTYwN2M1ODkxMDhkNzQxNWQ5ZGVlYTQ5ZDZkYjkxY2Qy
10
- YzAxZDAxMTFmNjI4Y2U0ODYzNmQyM2YwMzIyOGUzNjkzNDUwMWRlNjFkMTdl
11
- OGVhN2QxMjZmZDRhNWVlNzI2MDJhNjRjYzRiZDEyNTg4ZDU2Mjk=
9
+ YzhjY2Y1YWMxYzg1YWIyNzNiZGI0ZWM2OWZiY2ExNDFjNzJkYjZlMzM0OTJi
10
+ N2RlNzcxZjhmNjQ1YWFjOWJiY2NlNjQ2OGI5YWIyZWI4MjMyZGZhMTliYTQy
11
+ NzliNmIxYTUxYjI1OGYxNjU1ODllNzdkZDcxNTgwMTMxNTUzMjg=
12
12
  data.tar.gz: !binary |-
13
- OGYzODJjYTBmNzQwMTI4MWUyZDBkNDMwMGU3ZmY1YmU5MjdjZGE5ZDMyMzZi
14
- YzI0NDgwNmVjZTQ5NDE5ODY4NzZmYTEzODIwM2I1YmQ4N2JlMWMwMzgwMmM4
15
- ZTY0OTg4OTcxNWI5MWY2MjJhYTllZTE0ZmUzYTI1Y2U3Y2NhMmM=
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
- puts "- Deleting GFX records for MLS ##{p.mls_acct} in the local database that are not in the remote database..."
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
- puts "Purging #{class_type}..."
339
+ self.log("Purging #{class_type}...")
340
340
 
341
341
  # Get the total number of records
342
- puts "- Getting total number of records for #{class_type}..."
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
- puts "- 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 << case class_type
360
- when 'RES' then data[k]
361
- when 'COM' then data[k]
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
- puts "- Finding #{class_type} records in the local database that are not in the remote database..."
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
- puts "- Found #{ids_to_remove.count} #{class_type} records in the local database that are not in the remote database."
381
- puts "- Deleting #{class_type} records in the local database that shouldn't be there..."
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
- puts "- Finding #{class_type} records in the remote database that should be in the local database..."
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
- puts "- Found #{ids_to_add.count} #{class_type} records in the remote database that we need to add to the local database."
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
- puts "- Importing #{id}..."
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
- puts "Importing #{id}..."
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)
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.0.70'
2
+ VERSION = '0.0.71'
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.70
4
+ version: 0.0.71
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry