caboose-rets 0.1.167 → 0.1.172

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: 6c9c54d751e273164fdfd0417d2f0627e029f3eb45df52fbe8ccb269f83b3cdb
4
- data.tar.gz: d942c23cbd9b2a1b3d4eb1e774892e2707e8674fe532fe18c633bddae88d726f
3
+ metadata.gz: ffe1bb33340eca294f66a11d3b0d30cdb1f3c0bafac94d98f6c9e35cc5b936b6
4
+ data.tar.gz: 33e44cedfeed2d4dcc0aeff18f51c874617a7dd21b255d09ab883f6adea3c700
5
5
  SHA512:
6
- metadata.gz: 69641498cb92cc18e5cc05ef709c5b9a5db1b26dea9cd17347a2fd185e58c36e01715b3b0079c3cb9da6a72c1c8ed9b232559bccb65ca02bc81e359117e9faa0
7
- data.tar.gz: 336162f32bbb6c41030fa588c0389e7f954fb2f7a116cac5f67f8a0326e906139285b26ed1f773d55a023145357c750f4867205230d5145bcacd7f1b56f709a7
6
+ metadata.gz: 5c896ef5ef41cc6747e6ada1d539aa8274f754bcb25874bd7615c82f6f70c255718e9b00118682cf1dc45742031938fb6f9fa120a55c83dbf8dbe34ffeb2ebad
7
+ data.tar.gz: 3d0ed4a79ab4e28422570891a49c93ff1245fe12047b42f37544e5893e73c88719bff47c1b363ec83d4e18999a333b5a251ea5e021110d0e3cf6b71e1a74d8c9
@@ -1,4 +1,3 @@
1
-
2
1
  module CabooseRets
3
2
  class PropertiesController < ApplicationController
4
3
 
@@ -22,7 +21,27 @@ module CabooseRets
22
21
  params[:street_name_like][0] = '' if params[:street_name_like][0].to_i == 0
23
22
  end
24
23
  end
25
- where = @site && @site.id == 558 ? "(style ILIKE '%condo%' OR res_style ILIKE '%condo%' OR property_subtype ILIKE '%condo%' OR property_subtype ILIKE '%townhouse%')" : "(id is not null)"
24
+ where = "(id is not null)"
25
+ search_options = []
26
+
27
+ if (@site && @site.id == 558) || request.original_fullpath =~ /^\/tuscaloosa-condos-for-sale(.*?)$/
28
+ where = "(style ILIKE '%condo%' OR public_remarks ILIKE '%condo%' OR legal_description ILIKE '%unit%' OR res_style ILIKE '%condo%' OR property_subtype ILIKE '%condo%' OR property_subtype ILIKE '%townhouse%')"
29
+ end
30
+
31
+ if params[:location_query] && !params[:location_query].blank?
32
+ lc = params[:location_query]
33
+ if lc && lc.count > 0
34
+ lc.each do |lcid|
35
+ so = CabooseRets::SearchOption.where(:id => lcid).first
36
+ if so
37
+ search_options << "(#{so.field} = '#{so.value}')"
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ where2 = search_options.blank? ? "(id is not null)" : ("(" + search_options.join(' OR ') + ")")
44
+
26
45
  sortby = @site && @site.id == 558 ? "original_entry_timestamp" : CabooseRets::default_property_sort
27
46
  @saved_properties = CabooseRets::SavedProperty.where(:user_id => logged_in_user.id).pluck(:mls_number)
28
47
  @pager = Caboose::PageBarGenerator.new(params, {
@@ -60,32 +79,35 @@ module CabooseRets
60
79
  'foreclosure_yn' => '',
61
80
  'address_like' => '',
62
81
  'street_name_like' => '',
63
- 'street_number_like' => '',
82
+ 'street_number_like' => '',
64
83
  'postal_code' => '',
65
- 'postal_code_like' => '',
84
+ 'postal_code_like' => '',
66
85
  'status' => 'Active'
67
86
  },{
68
87
  'model' => 'CabooseRets::Property',
69
88
  'sort' => sortby,
70
89
  'desc' => true,
71
90
  'abbreviations' => {
72
- 'address_like' => 'street_number_concat_street_dir_prefix_concat_street_name_concat_street_suffix_concat_street_dir_suffix_like'
91
+ 'address_like' => 'street_number_concat_street_dir_prefix_concat_street_name_concat_street_suffix_concat_street_dir_suffix_like'
73
92
  },
74
93
  'skip' => ['status'],
94
+ 'additional_params' => ['location_query'],
75
95
  'base_url' => base_url,
76
96
  'items_per_page' => 10,
77
- 'additional_where' => [ where ]
97
+ 'additional_where' => [ where, where2 ]
78
98
  })
79
99
 
100
+ @pager.original_params[:test] == "hey"
101
+
80
102
  @properties = @pager.items
81
- if params[:waterfronts].present? then @properties.reject!{|p| p.waterfronts.blank?} end
103
+ if params[:waterfronts].present? then @properties = @properties.reject{|p| p.waterfronts.blank?} end
82
104
  # if params[:ftr_lotdesc] == 'golf' then @properties.reject!{|p| p.ftr_lotdesc != 'golf'} end
83
- if params[:foreclosure_yn] then @properties.reject!{|p| p.foreclosure_yn != "Y"} end
105
+ if params[:foreclosure_yn] then @properties = @properties.reject{|p| p.foreclosure_yn != "Y"} end
84
106
 
85
- @saved_search = nil
86
- if CabooseRets::SavedSearch.exists?(:uri => request.fullpath)
87
- @saved_search = CabooseRets::SavedSearch.where(:uri => request.fullpath).first
88
- end
107
+ # @saved_search = nil
108
+ # if CabooseRets::SavedSearch.exists?(:uri => request.fullpath)
109
+ # @saved_search = CabooseRets::SavedSearch.where(:uri => request.fullpath).first
110
+ # end
89
111
 
90
112
  @block_options = {
91
113
  :properties => @properties,
@@ -161,7 +161,7 @@ class CabooseRets::Property <ActiveRecord::Base
161
161
  self.matrix_unique_id = data['ListingKey']
162
162
  self.matrix_modified_dt = data['ModificationTimestamp']
163
163
  self.max_sqft = data['LivingArea']
164
- self.middle_school = data['MiddleSchool']
164
+ self.middle_school = data['MiddleOrJuniorSchool']
165
165
  # self.mineral_rights = data['MineralRights']
166
166
  self.min_sqft = data['LivingArea']
167
167
  self.misc_indoor_featuresa = data['BuildingFeatures']
@@ -696,7 +696,6 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
696
696
  end
697
697
  self.log2("Locking task...")
698
698
  task_started = self.lock_task
699
-
700
699
  begin
701
700
  overlap = 2.hours
702
701
  if (DateTime.now - self.last_purged).to_f >= 0.5
@@ -717,7 +716,6 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
717
716
  self.log2("Unlocking task if last updated...")
718
717
  self.unlock_task_if_last_updated(task_started)
719
718
  end
720
-
721
719
  # Start the same update process in 20 minutes
722
720
  self.log3(nil,nil,"Adding the update rets task for 20 minutes from now...")
723
721
  q = "handler like '%update_rets%'"
@@ -727,6 +725,8 @@ class CabooseRets::RetsImporter # < ActiveRecord::Base
727
725
  end
728
726
  # Delete old logs
729
727
  CabooseRets::Log.where("timestamp < ?",(DateTime.now - 30.days)).destroy_all
728
+ # Update search options
729
+ CabooseRets::SearchOption.delay(:queue => "rets").update_search_options
730
730
  end
731
731
 
732
732
  def self.last_updated
@@ -17,9 +17,7 @@ class CabooseRets::SearchOption < ActiveRecord::Base
17
17
  'Neighborhood' => ['subdivision'],
18
18
  'Street Name' => ['street_name'],
19
19
  'Property Type' => ['property_type'],
20
- 'MLS Number' => ['mls_number']
21
- #'feature',
22
- #'location',
20
+ 'MLS Number' => ['mls_number']
23
21
  }
24
22
  names.each do |name, fields|
25
23
  fields.each do |field|
@@ -32,11 +30,11 @@ class CabooseRets::SearchOption < ActiveRecord::Base
32
30
  end
33
31
 
34
32
  def self.update_search_options_for_field(name, field)
35
- q = ["select distinct(#{field}) from rets_properties where (status = ? or status = ?)", 'Pending', 'Active']
33
+ q = ["select distinct(#{field}) from rets_properties where status = ?", 'Active']
36
34
  rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
37
35
  rows.each do |row|
38
36
  so = self.where(:name => name, :field => field, :value => row[0]).first
39
- if so.nil?
37
+ if so.nil? && !field.blank?
40
38
  self.create(:name => name, :field => field, :value => row[0])
41
39
  else
42
40
  so.flag_for_delete = false
@@ -47,12 +45,12 @@ class CabooseRets::SearchOption < ActiveRecord::Base
47
45
 
48
46
  def self.results(str, count_per_name = 10)
49
47
  q = ["select * from (
50
- select name, field, value, row_number() over (partition by name order by field) as rownum
48
+ select id, name, field, value, row_number() over (partition by name order by field) as rownum
51
49
  from rets_search_options
52
50
  where lower(value) like ?
53
51
  ) tmp where rownum < #{count_per_name}", "%#{str}%"]
54
52
  rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
55
- arr = rows.collect{ |row| { :name => row[0], :field => row[1], :value => row[2] }}
53
+ arr = rows.collect{ |row| { :id => row[0].to_i, :name => row[1], :field => row[2], :text => row[3] }}
56
54
  return arr
57
55
  end
58
56
 
@@ -1,5 +1,4 @@
1
1
  domain = Caboose::Domain.where(:site_id => @site.id, :primary => true).first.domain
2
- hp = Caboose::Page.where(:site_id => @site.id, :title => "Home").first
3
2
  xml.instruct! :xml, :version => "1.0"
4
3
  xml.listings do
5
4
  xml.title @site.id == 558 ? "The Gray Group" : @site.description
@@ -39,7 +38,8 @@ xml.instruct! :xml, :version => "1.0"
39
38
  elsif !property.alternate_link.blank? && @use_alternate_link == true
40
39
  xml.url(property.alternate_link)
41
40
  else
42
- xml.url("https://" + domain + "/properties/#{property.mls_number}/details?utm_source=Nine&utm_medium=Facebook&utm_campaign=Retargeting")
41
+ url = "https://" + domain + "/properties/#{property.mls_number}/details?utm_source=Nine&utm_medium=Facebook&utm_campaign=Retargeting"
42
+ xml.url( url )
43
43
  end
44
44
  xml.year_built(property.year_built)
45
45
  if !property.property_type.blank?
@@ -12,12 +12,12 @@ xml.rss :version => "2.0", "xmlns:g" => "http://base.google.com/ns/1.0" do
12
12
  xml.g(:id, property.mls_number)
13
13
  xml.g(:title, property.full_address)
14
14
  xml.g(:description, property.public_remarks)
15
- xml.g(:link, "https://" + domain + "/properties/#{property.mls_number}/details?utm_source=Nine&utm_medium=Facebook&utm_campaign=Retargeting")
15
+ xml.g(:link, "https://" + domain + "/properties/#{property.mls_number}/details")
16
16
  first_image = property.images.first if property.images
17
17
  m = Caboose::Media.where(:id => first_image.media_id).first if first_image && !first_image.media_id.blank?
18
18
  if m && m.image
19
19
  xml.g(:image_link, "https:" + m.image.url(:large))
20
- else
20
+ else
21
21
  xml.g(:image_link, 'https://cabooseit.s3.amazonaws.com/rets/house.png')
22
22
  end
23
23
  if !property.construction_status.blank?
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.1.167'
2
+ VERSION = '0.1.172'
3
3
  end
@@ -283,9 +283,7 @@ namespace :caboose_rets do
283
283
  end
284
284
  CabooseRets::RetsImporter.log("Updating rets data...")
285
285
  task_started = lock_task
286
-
287
286
  begin
288
- # RetsImporter.update_all_after(last_updated - Rational(1,86400))
289
287
  CabooseRets::RetsImporter.update_after(last_updated, true)
290
288
  save_last_updated(task_started)
291
289
  unlock_task
@@ -294,6 +292,7 @@ namespace :caboose_rets do
294
292
  ensure
295
293
  unlock_task_if_last_updated(task_started)
296
294
  end
295
+ CabooseRets::SearchOption.delay(:queue => "rets").update_search_options
297
296
  end
298
297
 
299
298
  def last_updated
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.167
4
+ version: 0.1.172
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-07-23 00:00:00.000000000 Z
11
+ date: 2020-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caboose-cms
@@ -162,7 +162,7 @@ homepage: http://github.com/williambarry007/caboose-rets
162
162
  licenses:
163
163
  - MIT
164
164
  metadata: {}
165
- post_install_message:
165
+ post_install_message:
166
166
  rdoc_options: []
167
167
  require_paths:
168
168
  - lib
@@ -177,9 +177,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  - !ruby/object:Gem::Version
178
178
  version: '0'
179
179
  requirements: []
180
- rubyforge_project:
180
+ rubyforge_project:
181
181
  rubygems_version: 2.7.8
182
- signing_key:
182
+ signing_key:
183
183
  specification_version: 4
184
184
  summary: Library to download RETS data to a local website.
185
185
  test_files: