Class: Unit

Inherits:
ApplicationRecord show all
Defined in:
app/models/unit.rb

Class Method Summary collapse

Class Method Details

.get_inspectable_units(property_id) ⇒ Object



27
28
29
30
31
# File 'app/models/unit.rb', line 27

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



22
23
24
25
26
# File 'app/models/unit.rb', line 22

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



14
15
16
17
18
19
20
# File 'app/models/unit.rb', line 14

def self.search(property_id)
  if property_id
    where('property_id = ?', property_id.to_s)
  else
    all
  end
end