Created method extremes
Created method to return maximum, minimum and average data
This commit is contained in:
parent
a364392f57
commit
d660f1a0be
@ -12,11 +12,11 @@ class Rate < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.extremes(type, value)
|
def self.extremes(type, value)
|
||||||
everage = self.find_rate.public_send(type, value)
|
hash = self.group("date(created_at)").public_send(type, value)
|
||||||
everage.ceil(2)
|
hash.transform_keys!{ |k| k.to_date.strftime('%d-%m') }
|
||||||
|
hash.transform_values!{ |v| v.ceil(2) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.find_rate
|
def self.find_rate
|
||||||
where(created_at: Date.today.all_day)
|
where(created_at: Date.today.all_day)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user