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 +4 -4
- data/app/models/caboose_rets/rets_importer.rb +56 -50
- data/lib/caboose_rets/version.rb +1 -1
- data/lib/tasks/caboose_rets.rake +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 084c9f620a345eab5f77d03cd5c2fbe4302bc595
|
4
|
+
data.tar.gz: 2b077bd12c128c7e497f338d928522b672405236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,
|
124
|
-
self.delay(:priority => 10, :queue => 'rets').update_helper('Member' , date_modified,
|
125
|
-
self.delay(:priority => 10, :queue => 'rets').update_helper('OpenHouse', date_modified,
|
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],
|
160
|
-
when 'Member' then self.delay(:priority => 10, :queue => 'rets').import_agent( data[k],
|
161
|
-
when 'OpenHouse' then self.delay(:priority => 10, :queue => 'rets').import_open_house(data[k],
|
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
|
-
|
477
|
+
# def self.get_media_urls
|
478
|
+
# m = self.meta(class_type)
|
473
479
|
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
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
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
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
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
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
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
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).
|
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
|
|
data/lib/caboose_rets/version.rb
CHANGED
data/lib/tasks/caboose_rets.rake
CHANGED
@@ -64,8 +64,7 @@ namespace :caboose_rets do
|
|
64
64
|
|
65
65
|
desc "Import Image"
|
66
66
|
task :img => :environment do
|
67
|
-
|
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.
|
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-
|
11
|
+
date: 2018-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: caboose-cms
|