app/models/c80_estate/property.rb in c80_estate-0.1.0.23 vs app/models/c80_estate/property.rb in c80_estate-0.1.0.24

- old
+ new

@@ -19,9 +19,20 @@ has_many :areas, :dependent => :destroy has_many :comments, :dependent => :destroy has_many :sevents, :dependent => :destroy has_many :pstats, :dependent => :destroy + # scope :sort_chart, -> {order(:ord => :asc)} + + def self.sorted_chart + self.all.sort_by(&:busy_koef).reverse! + end + + def busy_koef + pp = Pstat.busy_coef(prop_id: self.id, atype_id: nil) + pp[:busy_coef].to_f + end + # этот метод для ActiveRecordCollection of Properties def self.areas_count ac = 0 self.all.each do |prop| ac += prop.areas.count \ No newline at end of file