Created method extremes

Created method to return maximum, minimum and average data
This commit is contained in:
Luiz F Picolo 2021-11-02 22:44:27 -04:00
parent a364392f57
commit d660f1a0be

View File

@ -12,11 +12,11 @@ class Rate < ActiveRecord::Base
end
def self.extremes(type, value)
everage = self.find_rate.public_send(type, value)
everage.ceil(2)
hash = self.group("date(created_at)").public_send(type, value)
hash.transform_keys!{ |k| k.to_date.strftime('%d-%m') }
hash.transform_values!{ |v| v.ceil(2) }
end
def self.find_rate
where(created_at: Date.today.all_day)
end