caboose-rets 0.1.41 → 0.1.42

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 797cfd1b91e89149b9fdb0230e37a0f1161874a7
4
- data.tar.gz: a78bce9795e10d4211b958b2fc590175dee3749f
3
+ metadata.gz: 084c9f620a345eab5f77d03cd5c2fbe4302bc595
4
+ data.tar.gz: 2b077bd12c128c7e497f338d928522b672405236
5
5
  SHA512:
6
- metadata.gz: 0ae933b766f267a4d30e62349d74e8b793845dd5d8ee17eabd26e2b5a2fafe1b8bf7b63b3cdbc7ff2bac6d8799e7206c92c5cd0029090e45aa387a95f0cd4d61
7
- data.tar.gz: bb70b439366533694fcc71344ac4b113358e2aea2b7b92f6f4ed8d6e952526cdba6456e269c46e5f5d7b864b35c7fd6a7cdca428de7ff5aa41f1a77878e0fe59
6
+ metadata.gz: 61ea5917a85940109654b4616f8891cb3b03edb18be919eb9531804d93e2d661a767f5ad093f43f700677f3a934365af46a116860ec8c406deecae75ba1b129a
7
+ data.tar.gz: 60af3840905cda8184b8328b4bfb1b947620d6863aa08b91b729c8e6502b8cacfd0515b496e1d90ae9f44682281a10491aec96b6a0fae29063100419ab35556a
@@ -120,9 +120,9 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
120
120
  def self.update_after(date_modified, save_images = true)
121
121
  self.log "Updating after #{date_modified}"
122
122
  self.delay(:priority => 10, :queue => 'rets').update_helper('Property' , date_modified, save_images)
123
- self.delay(:priority => 10, :queue => 'rets').update_helper('Office' , date_modified, save_images)
124
- self.delay(:priority => 10, :queue => 'rets').update_helper('Member' , date_modified, save_images)
125
- self.delay(:priority => 10, :queue => 'rets').update_helper('OpenHouse', date_modified, save_images)
123
+ self.delay(:priority => 10, :queue => 'rets').update_helper('Office' , date_modified, false)
124
+ self.delay(:priority => 10, :queue => 'rets').update_helper('Member' , date_modified, false)
125
+ self.delay(:priority => 10, :queue => 'rets').update_helper('OpenHouse', date_modified, false)
126
126
  end
127
127
 
128
128
  def self.update_helper(class_type, date_modified, save_images = true)
@@ -156,9 +156,9 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
156
156
  self.log data
157
157
  case class_type
158
158
  when 'Property' then self.delay(:priority => 10, :queue => 'rets').import_properties(data[k], save_images)
159
- when 'Office' then self.delay(:priority => 10, :queue => 'rets').import_office( data[k], save_images)
160
- when 'Member' then self.delay(:priority => 10, :queue => 'rets').import_agent( data[k], save_images)
161
- when 'OpenHouse' then self.delay(:priority => 10, :queue => 'rets').import_open_house(data[k], save_images)
159
+ when 'Office' then self.delay(:priority => 10, :queue => 'rets').import_office( data[k], false)
160
+ when 'Member' then self.delay(:priority => 10, :queue => 'rets').import_agent( data[k], false)
161
+ when 'OpenHouse' then self.delay(:priority => 10, :queue => 'rets').import_open_house(data[k], false)
162
162
  end
163
163
  end
164
164
  end
@@ -302,6 +302,12 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
302
302
  end
303
303
  end
304
304
 
305
+ def self.download_missing_images
306
+ CabooseRets::Property.where("photo_count = ? OR photo_count is null", '').all.each do |p|
307
+ self.delay(:priority => 10, :queue => 'rets').import_properties(p.mls_number, true)
308
+ end
309
+ end
310
+
305
311
  def self.download_agent_image(agent)
306
312
  # self.log "Saving image for #{agent.first_name} #{agent.last_name}..."
307
313
  # begin
@@ -468,53 +474,53 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
468
474
  end
469
475
  end
470
476
 
471
- def self.get_media_urls
472
- m = self.meta(class_type)
477
+ # def self.get_media_urls
478
+ # m = self.meta(class_type)
473
479
 
474
- # Get the total number of records
475
- params = {
476
- :search_type => m.search_type,
477
- :class => class_type,
478
- :query => "(#{m.matrix_modified_dt}=#{date_modified}T00:00:01+)",
479
- :standard_names_only => true,
480
- :timeout => -1
481
- }
482
- self.client.search(params.merge({ :count => 1 }))
483
- count = self.client.rets_data[:code] == "20201" ? 0 : self.client.rets_data[:count]
484
- batch_count = (count.to_f/5000.0).ceil
480
+ # # Get the total number of records
481
+ # params = {
482
+ # :search_type => m.search_type,
483
+ # :class => class_type,
484
+ # :query => "(#{m.matrix_modified_dt}=#{date_modified}T00:00:01+)",
485
+ # :standard_names_only => true,
486
+ # :timeout => -1
487
+ # }
488
+ # self.client.search(params.merge({ :count => 1 }))
489
+ # count = self.client.rets_data[:code] == "20201" ? 0 : self.client.rets_data[:count]
490
+ # batch_count = (count.to_f/5000.0).ceil
485
491
 
486
- ids = []
487
- k = m.remote_key_field
488
- (0...batch_count).each do |i|
489
- self.client.search(params.merge({ :select => [k], :limit => 5000, :offset => 5000*i })) do |data|
490
- ids << data[k]
491
- end
492
- end
492
+ # ids = []
493
+ # k = m.remote_key_field
494
+ # (0...batch_count).each do |i|
495
+ # self.client.search(params.merge({ :select => [k], :limit => 5000, :offset => 5000*i })) do |data|
496
+ # ids << data[k]
497
+ # end
498
+ # end
493
499
 
494
- if ids.count > 0
495
- # Delete any records in the local database that shouldn't be there
496
- t = m.local_table
497
- k = m.local_key_field
498
- query = ["delete from #{t} where #{k} not in (?)", ids]
499
- ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
500
+ # if ids.count > 0
501
+ # # Delete any records in the local database that shouldn't be there
502
+ # t = m.local_table
503
+ # k = m.local_key_field
504
+ # query = ["delete from #{t} where #{k} not in (?)", ids]
505
+ # ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
500
506
 
501
- # Find any ids in the remote database that should be in the local database
502
- query = "select distinct #{k} from #{t}"
503
- rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
504
- local_ids = rows.collect{ |row| row[k] }
505
- ids_to_add = ids - local_ids
506
- ids_to_add.each do |id|
507
- self.log("Importing #{id}...")
508
- case class_type
509
- when "Property" then self.delay(:priority => 10, :queue => 'rets').import_properties(id, true)
510
- when "Office" then self.delay(:priority => 10, :queue => 'rets').import_office(id, false)
511
- when "Member" then self.delay(:priority => 10, :queue => 'rets').import_agent(id, false)
512
- when "OpenHouse" then self.delay(:priority => 10, :queue => 'rets').import_open_house(id, false)
513
- end
514
- end
515
- end
507
+ # # Find any ids in the remote database that should be in the local database
508
+ # query = "select distinct #{k} from #{t}"
509
+ # rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
510
+ # local_ids = rows.collect{ |row| row[k] }
511
+ # ids_to_add = ids - local_ids
512
+ # ids_to_add.each do |id|
513
+ # self.log("Importing #{id}...")
514
+ # case class_type
515
+ # when "Property" then self.delay(:priority => 10, :queue => 'rets').import_properties(id, true)
516
+ # when "Office" then self.delay(:priority => 10, :queue => 'rets').import_office(id, false)
517
+ # when "Member" then self.delay(:priority => 10, :queue => 'rets').import_agent(id, false)
518
+ # when "OpenHouse" then self.delay(:priority => 10, :queue => 'rets').import_open_house(id, false)
519
+ # end
520
+ # end
521
+ # end
516
522
 
517
- end
523
+ # end
518
524
 
519
525
  #=============================================================================
520
526
  # Logging
@@ -547,7 +553,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
547
553
 
548
554
  begin
549
555
  overlap = 30.seconds
550
- if (DateTime.now - self.last_purged).to_i >= 1
556
+ if (DateTime.now - self.last_purged).to_f >= 0.5
551
557
  self.purge
552
558
  self.save_last_purged(task_started)
553
559
  # Keep this in here to make sure all updates are caught
@@ -556,7 +562,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
556
562
 
557
563
  self.log2("Updating after #{self.last_updated.strftime("%FT%T%:z")}...")
558
564
  self.update_after(self.last_updated - overlap)
559
-
565
+ self.download_missing_images
560
566
  self.log2("Saving the timestamp for when we updated...")
561
567
  self.save_last_updated(task_started)
562
568
 
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.1.41'
2
+ VERSION = '0.1.42'
3
3
  end
@@ -64,8 +64,7 @@ namespace :caboose_rets do
64
64
 
65
65
  desc "Import Image"
66
66
  task :img => :environment do
67
- p = CabooseRets::Property.where(:matrix_unique_id => "9233280").first
68
- CabooseRets::RetsImporter.download_property_images(p)
67
+ CabooseRets::RetsImporter.download_missing_images
69
68
  end
70
69
 
71
70
  desc "Reimports Property Images"
@@ -142,7 +141,7 @@ namespace :caboose_rets do
142
141
 
143
142
  begin
144
143
  # RetsImporter.update_all_after(last_updated - Rational(1,86400))
145
- CabooseRets::RetsImporter.update_after(last_updated)
144
+ CabooseRets::RetsImporter.update_after(last_updated, true)
146
145
  save_last_updated(task_started)
147
146
  unlock_task
148
147
  rescue
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.1.41
4
+ version: 0.1.42
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
11
+ date: 2018-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caboose-cms