class Recorder::Application
Public Instance Methods
get_data(period=:whole)
click to toggle source
# File lib/application.rb, line 120 def get_data(period=:whole) @data = Data.order('created_at DESC') weight_data,bodyfat_data=[],[] today = Date.today week_before=Time.parse((today-7).strftime) month_before=Time.parse((today-28).strftime) recent=Time.parse('2016-8-26') @data.each{|d| case period when :whole when :recent next if d.date < recent when :week next if d.date < week_before when :month next if d.date < month_before end weight_data << [d.date,d.weight] bodyfat_data << [d.date,d.bodyfat] } return weight_data,bodyfat_data end