Class: CabooseRets::SavedSearch

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/caboose_rets/saved_search.rb

Instance Method Summary collapse

Instance Method Details

#modelObject



34
35
36
37
38
39
# File 'app/models/caboose_rets/saved_search.rb', line 34

def model
  case self.property_type
    when 'property'     then return CabooseRets::Property      
  end  
  return nil
end

#new_resultsObject



30
31
32
# File 'app/models/caboose_rets/saved_search.rb', line 30

def new_results
  return self.results.reject{|r|r.date_created.to_date > self.date_last.to_date }
end

#new_results?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/caboose_rets/saved_search.rb', line 26

def new_results?()
  return false if self.new_results.nil? || self.new_results == []
end

#resultsObject



21
22
23
24
# File 'app/models/caboose_rets/saved_search.rb', line 21

def results()
  @gen = Caboose::PageBarGenerator.new(self.params, self.search_fields, self.search_options)
  return @gen.items
end

#search_fieldsObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'app/models/caboose_rets/saved_search.rb', line 41

def search_fields()
  return {
    'area'                     => '',
      'area_like'                => '',      
      'acreage_gte'              => '',
      'acreage_lte'              => '',
      'city'                     => '',
      'city_like'                => '',
      'county_or_parish'         => '',
      'county_or_parishy_like'   => '',
      'current_price_gte'        => '',
      'current_price_lte'        => '',
      'bedrooms_gte'             => '',
      'bedrooms_lte'             => '',
      'property_type'            => '',
      'property_subtype'         => '',
      'sqft_total_gte'           => '',
      'sqft_total_gte_lte'       => '',
      'neighborhood'             => '',
      'elementary_school'        => '',
      'middle_school'            => '',
      'high_school'              => '',          
      'public_remarks_like'      => '',
      'waterfronts'              => '',
      'waterfronts_not_null'     => '',
      'mls_number'               => '',
      'subdivision'              => '',
      'style'                    => '',
      'foreclosure_yn'           => '',
      'address_like'             => '',
      'street_name_like'         => '',
      'street_num_like'          => '',
      'postal_code'              => '',
      'postal_code_like'         => '',        
      'status'                   => 'Active'
    }
end

#search_optionsObject



79
80
81
82
83
84
85
86
87
# File 'app/models/caboose_rets/saved_search.rb', line 79

def search_options
  return {
    'model'           => self.model.to_s,
    'sort'            => 'current_price ASC, mls',
    'desc'            => false,
    'base_url'        => "/#{self.property_type}",
    'items_per_page'  => 10
  }
end