Class: Unit
- Inherits:
-
ApplicationRecord
- Object
- ActiveRecord::Base
- ApplicationRecord
- Unit
- Defined in:
- app/models/unit.rb
Class Method Summary collapse
- .get_inspectable_units(property_id) ⇒ Object
- .get_property_units(property_id) ⇒ Object
- .search(property_id) ⇒ Object
- .total_inspectable_units(property_id) ⇒ Object
Class Method Details
.get_inspectable_units(property_id) ⇒ Object
26 27 28 29 30 |
# File 'app/models/unit.rb', line 26 def self.get_inspectable_units(property_id) units = Unit.where(property_id: property_id).where("properties->>'uninspectable' = ? OR properties->>'uninspectable' IS NULL", 'None') sorted_units = ApplicationHelper.key_merge_sort(units, 'id', 0, 1) sorted_units end |
.get_property_units(property_id) ⇒ Object
21 22 23 24 25 |
# File 'app/models/unit.rb', line 21 def self.get_property_units(property_id) units = Unit.where(property_id: property_id) sorted_units = ApplicationHelper.key_merge_sort(units, 'id', 0, 1) sorted_units end |
.search(property_id) ⇒ Object
13 14 15 16 17 18 19 |
# File 'app/models/unit.rb', line 13 def self.search(property_id) if property_id where('property_id = ?', property_id.to_s) else all end end |
.total_inspectable_units(property_id) ⇒ Object
31 32 33 |
# File 'app/models/unit.rb', line 31 def self.total_inspectable_units(property_id) Unit.where(property_id: property_id).where("properties->>'uninspectable' = ? OR properties->>'uninspectable' IS NULL", 'None').count end |