Class: Building
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Building
- Defined in:
- app/models/building.rb
Class Method Summary collapse
- .get_inspectable_buildings(property_id) ⇒ Object
- .get_property_buildings(property_id) ⇒ Object
- .search(building_name, property_id) ⇒ Object
- .total_inspectable_buildings(property_id) ⇒ Object
Class Method Details
.get_inspectable_buildings(property_id) ⇒ Object
29 30 31 32 33 |
# File 'app/models/building.rb', line 29 def self.get_inspectable_buildings(property_id) buildings = Building.where(property_id: property_id).where("properties->>'uninspectable' = ? OR properties->>'uninspectable' IS NULL", 'None') sorted_buildings = ApplicationHelper.key_merge_sort(buildings, 'id', 0, 1) sorted_buildings end |
.get_property_buildings(property_id) ⇒ Object
24 25 26 27 28 |
# File 'app/models/building.rb', line 24 def self.get_property_buildings(property_id) buildings = Building.where(property_id: property_id) sorted_buildings = ApplicationHelper.key_merge_sort(buildings, 'id', 0, 1) sorted_buildings end |
.search(building_name, property_id) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'app/models/building.rb', line 15 def self.search(building_name, property_id) if building_name where(['building_name LIKE ?', "%#{building_name}%"]) .where(['property_id = ?', property_id.to_s]) else all end end |
.total_inspectable_buildings(property_id) ⇒ Object
34 35 36 |
# File 'app/models/building.rb', line 34 def self.total_inspectable_buildings(property_id) Building.where(property_id: property_id).where("properties->>'uninspectable' = ? OR properties->>'uninspectable' IS NULL", 'None').count end |