caboose-rets 0.1.123 → 0.1.124

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
  SHA256:
3
- metadata.gz: 108046d4d13f4b74dde3d66b18ac417f344d6d3a7309c691058c8639995eb468
4
- data.tar.gz: 425c84172109c6ad553a4085f5fad4ceda2e529a179677328331d47fe6a084f6
3
+ metadata.gz: f0079470eb419441f857d8b8c7e813b626ac09d8e369274e93fbe8ea4dceb445
4
+ data.tar.gz: 7cf488f2bbed2ce5efc4aff3d2ed88d0aad4b5d2f549b9e07d468bb51538be59
5
5
  SHA512:
6
- metadata.gz: 8edfa0c49a4b2a55779f79b3cb41edada3d0805192583cc90116a0b9776b4c6c2cebd80e30b7411d2b4def644e494ee4a3bf8061cfaa1713f01b63a4eb357273
7
- data.tar.gz: 70f675774ec47d16d6e920ca250262f7c6202c328793688950b50e1e4de93aafdab363967cc281f0fb559338024f7c61c9c8a2a09f6530d7e224e8b0ec8952c2
6
+ metadata.gz: c5a0e23a99e65a5d67b6986d3c0fdb9ea1566acdbe5ded46fb8d36f4a3bea0f7357ef35ca848e7497583017e210f6fe507db6e696425b4a1acf5f666f544bca6
7
+ data.tar.gz: 3d493f50c2ff29e2c54b81435e95bee23dcdcc96e0da893d2ea88f424a065f175aed07ff744e4e573a91bd8447aa65a271334a4c6757c86bb040ada1fe020410
@@ -3,7 +3,7 @@ class CabooseRets::Agent < ActiveRecord::Base
3
3
 
4
4
  has_one :meta, :class_name => 'AgentMeta', :primary_key => 'mls_id', :foreign_key => 'la_code'
5
5
  has_many :properties
6
- attr_accessible :id, :agent_number, :matrix_unique_id, :sort_order, :mls_id
6
+ attr_accessible :id, :agent_number, :matrix_unique_id, :sort_order, :mls_id, :last_updated
7
7
  after_initialize :fix_name
8
8
 
9
9
  def image
@@ -225,9 +225,29 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
225
225
  end
226
226
 
227
227
  def self.import_agent(mls_id, save_images = true)
228
- self.log3('Agent',mls_id,"Importing Agent #{mls_id}...")
229
- self.import('Member', "(MemberMlsId=#{mls_id})")
230
228
  a = CabooseRets::Agent.where(:mls_id => mls_id.to_s).first
229
+ if a.nil?
230
+ self.log3('Agent',mls_id,"Importing new Agent #{mls_id}...")
231
+ self.import('Member', "(MemberMlsId=#{mls_id})")
232
+ a = CabooseRets::Agent.where(:mls_id => mls_id.to_s).first
233
+ if a
234
+ a.last_updated = DateTime.now
235
+ a.save
236
+ end
237
+ else
238
+ lu = a.last_updated.blank? ? 0 : a.last_updated.to_time.to_i
239
+ now = DateTime.now.to_time.to_i
240
+ diff = now - lu
241
+ is_old = diff > 86400 # 24 hours
242
+ if is_old
243
+ self.log3('Agent',mls_id,"Updating existing Agent #{mls_id}...")
244
+ self.import('Member', "(MemberMlsId=#{mls_id})")
245
+ a.last_updated = DateTime.now
246
+ a.save
247
+ else
248
+ self.log3('Agent',mls_id,"Skipping importing Agent #{mls_id} because last_updated is today...")
249
+ end
250
+ end
231
251
  end
232
252
 
233
253
  def self.import_open_house(oh_id, save_images = true)
@@ -35,7 +35,8 @@ class CabooseRets::Schema < Caboose::Utilities::Schema
35
35
  [ :photo_count , :text ],
36
36
  [ :photo_modification_timestamp , :text ],
37
37
  [ :sort_order , :integer ],
38
- [ :slug , :text ]
38
+ [ :slug , :text ],
39
+ [ :last_updated , :datetime ]
39
40
  ],
40
41
  CabooseRets::AgentMeta => [
41
42
  [ :la_code , :string ],
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.1.123'
2
+ VERSION = '0.1.124'
3
3
  end
@@ -211,6 +211,11 @@ namespace :caboose_rets do
211
211
  CabooseRets::RetsImporter.import_properties(args.mls_number, save_images)
212
212
  end
213
213
 
214
+ desc "Import one agent"
215
+ task :import_one_agent, [:mls_number] => :environment do |t, args|
216
+ CabooseRets::RetsImporter.import_agent(args.mls_number, false)
217
+ end
218
+
214
219
  desc "Purge rets data"
215
220
  task :purge => :environment do
216
221
  CabooseRets::RetsImporter.purge_helper('Property', '2013-08-06')
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.123
4
+ version: 0.1.124
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-03 00:00:00.000000000 Z
11
+ date: 2019-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caboose-cms