caboose-rets 0.1.118 → 0.1.119

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 520c96e0fed6b83c66b12a6424749042784ee05b66b4f4cdf957c1918a12d091
4
- data.tar.gz: '089e17dcb5d154476b9f573773f36e5429d2e9473290611a18a86852aa568970'
3
+ metadata.gz: aeb377c80744124361580027e24e96fc75c3a6831cf6d718d14f52b675d9912f
4
+ data.tar.gz: d0ce221bbc719c75b0c5fc201e247dcaf0157be015a66b490ec948b28ff9f967
5
5
  SHA512:
6
- metadata.gz: 78eed3f8ceb5fd9bf49fb68ceff5fe607010c00405cefaaec7c3058ee3e8b007534606eed8a3a6a3a8863a43d2d38bd3216613e62f8da40011c392ba020ebe7b
7
- data.tar.gz: 5e7e714bb1d1fb23cacbe317d043529a8bcf3e21c32c9dd5a9987d0517407b297b835b1cd0400571155b566d25c74992e1a5612cc5161a7c850128095605da20
6
+ metadata.gz: e23514e4d183cf3cf8155b160561fe44b857fe6101e6bab41f4181205e89b62afcbf6f71f3ffbddd8ad11399f11f82ee1e76e265c78b39d4716303d4d3f16942
7
+ data.tar.gz: 5c12d11a6a3bbd966e9a671c95064458c017650de5393b064570ad19405caf5b83c7f34b2a14b4eeb13180fafec5993ba81b5e004cbf558a0c353c63b7c4e46a
@@ -18,6 +18,19 @@ class CabooseRets::Property <ActiveRecord::Base
18
18
  CabooseRets::RetsImporter.import_properties(self.mls_number, true)
19
19
  end
20
20
 
21
+ def featured_photo_url
22
+ img_url = nil
23
+ self.images.each do |img|
24
+ m = Caboose::Media.where(:id => img.media_id).first
25
+ if m && m.image && m.image.url(:large)
26
+ img_url = m.image.url(:large)
27
+ return img_url
28
+ break
29
+ end
30
+ end
31
+ return img_url
32
+ end
33
+
21
34
  def agent
22
35
  CabooseRets::Agent.where(:mls_id => self.list_agent_mls_id).first
23
36
  end
@@ -275,7 +275,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
275
275
  # rows = ActiveRecord::Base.connection.select_all(ActiveRecord::Base.send(:sanitize_sql_array, query))
276
276
  # local_ids = rows.collect{ |row| row['media_id'] }
277
277
  # ids_to_remove = local_ids - ids
278
- # if ids_to_remove && ids_to_remove.count > 0
278
+ # if ids_to_remove && ids_to_remove.count > 0
279
279
  # query = ["delete from rets_media where media_id in (?)", ids_to_remove]
280
280
  # ActiveRecord::Base.connection.execute(ActiveRecord::Base.send(:sanitize_sql_array, query))
281
281
  # end
@@ -303,6 +303,7 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
303
303
  m.media_order = ind
304
304
  m.media_type = 'Photo'
305
305
  cm = nil
306
+ old_cm_id = is_new ? nil : m.media_id
306
307
  begin
307
308
  cm = Caboose::Media.new
308
309
  cm.image = File.open(tmp_path)
@@ -317,6 +318,11 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
317
318
  if is_new
318
319
  self.log3("Media",p.mls_number,"Created new RetsMedia object #{m.id}, media_id = #{m.media_id}")
319
320
  else
321
+ old_media = Caboose::Media.where(:id => old_cm_id).first
322
+ if old_media
323
+ self.log3("Media",p.mls_number,"Deleting old CabooseMedia #{old_media.id}")
324
+ old_media.destroy
325
+ end
320
326
  self.log3("Media",p.mls_number,"RetsMedia object already existed #{m.id}, updated media_id = #{m.media_id}")
321
327
  end
322
328
  self.log3("Media",p.mls_number,"Image rets_media_#{headers['content-id']}_#{ind} saved")
@@ -548,7 +554,6 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
548
554
  ids_to_remove = local_ids - ids
549
555
  self.log3(class_type,nil,"Found #{ids_to_remove.count} #{class_type} records in the local database that are not in the remote database.")
550
556
 
551
-
552
557
  # Delete all RetsMedia and CabooseMedia for the deleted property listings
553
558
  if class_type == 'Property' && ids_to_remove && ids_to_remove.count > 0
554
559
  self.log3(class_type,nil,"Deleting Media objects that shouldn't be there...")
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.1.118'
2
+ VERSION = '0.1.119'
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.1.118
4
+ version: 0.1.119
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-01 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caboose-cms