caboose-rets 0.1.8 → 0.1.9

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: 8b9427dfa683fee1e5be758b91721d68fe8ce144
4
- data.tar.gz: 17b46b6354a55b034e0d5443851d5de066a1790a
3
+ metadata.gz: 1ff44b589fbd88839a2b88f34a89dbbe86acf160
4
+ data.tar.gz: 6d1aff861f630f9b71740aabb5aef5e32d0f30ef
5
5
  SHA512:
6
- metadata.gz: b274434916e0c7c0ca9c3f39d29cc6e44d3c260ab977288253a666888d426ccfa802a5176b57af81de03d80009c75b65e8de0010498e2e0e89a7f674bc25fc85
7
- data.tar.gz: 2ccd0afd3c0410df03885d134acd9bdda95cf2fa915f885a07df7bde701e57a54967026475352e55783dc5339996d291f60dc59daf9fb19ea4857fc15f4d9ed6
6
+ metadata.gz: 637d77f8aa46d07f7ba78a921359507dc69a0ea69fe36472b0f4f834fa1a10c3622bb59ba297c5780ce40e52cd2cff98832eb540153a955c60788009854978e6
7
+ data.tar.gz: b0d3d5d8ed6fad15dbf3fbdcd3138ee8b4286e3415e35c7e84fe23ad33ccbd21ddccd17345738a106b02a5576240684ed5d8a3645cb91c1349369c595397de5a
@@ -19,10 +19,16 @@ module CabooseRets
19
19
  end
20
20
  end
21
21
 
22
- @pager = Caboose::PageBarGenerator.new(params, {
22
+ @pager = Caboose::PageBarGenerator.new(params, {
23
+ 'area' => '',
24
+ 'area_like' => '',
23
25
  'name' => '',
24
26
  'acreage_gte' => '',
25
27
  'acreage_lte' => '',
28
+ 'city' => '',
29
+ 'city_like' => '',
30
+ 'county' => '',
31
+ 'county_like' => '',
26
32
  'current_price_gte' => '',
27
33
  'current_price_lte' => '',
28
34
  'bedrooms_gte' => '',
@@ -45,10 +51,13 @@ module CabooseRets
45
51
  'address_like' => '',
46
52
  'street_name_like' => '',
47
53
  'street_num_like' => '',
54
+ 'zip' => '',
55
+ 'zip_like' => '',
48
56
  'date_created_gte' => '',
49
57
  'date_created_lte' => '',
50
58
  'date_modified_gte' => '',
51
59
  'date_modified_lte' => '',
60
+
52
61
  'status' => 'Active'
53
62
  },{
54
63
  'model' => 'CabooseRets::ResidentialProperty',
@@ -845,9 +845,10 @@ class CabooseRets::Schema < Caboose::Utilities::Schema
845
845
  [ :notify , :boolean ]
846
846
  ],
847
847
  CabooseRets::SearchOption => [
848
- [ :name , :string ],
849
- [ :field , :string ],
850
- [ :value , :string ]
848
+ [ :name , :string ],
849
+ [ :field , :string ],
850
+ [ :value , :string ],
851
+ [ :flag_for_delete , :boolean , { :default => false }]
851
852
  ],
852
853
  Caboose::Site => [
853
854
  [ :use_rets , :boolean, { :default => false }]
@@ -1,10 +1,13 @@
1
1
  class CabooseRets::SearchOption < ActiveRecord::Base
2
2
  self.table_name = "rets_search_options"
3
3
 
4
- attr_accessible :id, :name, :field, :value
4
+ attr_accessible :id, :name, :field, :value, :flag_for_delete
5
5
 
6
6
  def self.update_search_options
7
7
 
8
+ # Flag all for delete
9
+ self.update_all(:flag_for_delete => true)
10
+
8
11
  names = {
9
12
  'City' => ['city'],
10
13
  'County' => ['county'],
@@ -19,13 +22,25 @@ class CabooseRets::SearchOption < ActiveRecord::Base
19
22
  #'location',
20
23
  }
21
24
  names.each do |name, fields|
22
- fields.each do |field|
23
- q = ["select distinct(#{field}) from rets_residential"]
24
- rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
25
- rows.each do |row|
26
- so = self.where(:name => name, :field => field, :value => row[0]).first
27
- self.create( :name => name, :field => field, :value => row[0]) if so.nil?
28
- end
25
+ fields.each do |field|
26
+ self.update_search_options_for_field(name, field)
27
+ end
28
+ end
29
+
30
+ # Delete all flagged
31
+ self.where(:flag_for_delete => true).destroy_all
32
+ end
33
+
34
+ def self.update_search_options_for_field(name, field)
35
+ q = ["select distinct(#{field}) from rets_residential where (status = ? or status = ?)", 'Pending', 'Active']
36
+ rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
37
+ rows.each do |row|
38
+ so = self.where(:name => name, :field => field, :value => row[0]).first
39
+ if so.nil?
40
+ self.create(:name => name, :field => field, :value => row[0])
41
+ else
42
+ so.flag_for_delete = false
43
+ so.save
29
44
  end
30
45
  end
31
46
  end
@@ -33,8 +48,8 @@ class CabooseRets::SearchOption < ActiveRecord::Base
33
48
  def self.results(str, count_per_name = 10)
34
49
  q = ["select * from (
35
50
  select name, field, value, row_number() over (partition by name order by field) as rownum
36
- from rets_search_options
37
- where lower(value) like ?
51
+ from rets_search_options
52
+ where lower(value) like ?
38
53
  ) tmp where rownum < #{count_per_name}", "%#{str}%"]
39
54
  rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, q))
40
55
  arr = rows.collect{ |row| { :name => row[0], :field => row[1], :value => row[2] }}
@@ -1,3 +1,3 @@
1
1
  module CabooseRets
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-22 00:00:00.000000000 Z
11
+ date: 2016-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: caboose-cms