def moving_averages!(days)
      subselects = Metric.subselects_with_day(days).join(",")
      metric_with_calculated_averages = Metric.find_by_sql("SELECT fulldate, fulldate AS d, year, monthofyear AS month, dayofyear AS day, '#{days}' AS movingaverage, #{subselects} FROM heart_metrics WHERE fulldate = '#{fulldate}' AND movingaverage = 0")
      metric_with_calculated_averages.first.attributes.each do |name, value|
        next if Metric.metadata.include?(name)
        next if Metric.groupbydata.include?(name)
          self.send(name+"=",value)
      end
    end
def moving_averages!(days)
      subselects = Metric.subselects_with_day(days).join(",")
      metric_with_calculated_averages = Metric.find_by_sql("SELECT fulldate, fulldate AS d, year, monthofyear AS month, dayofyear AS day, '#{days}' AS movingaverage, #{subselects} FROM heart_metrics WHERE fulldate = '#{fulldate}' AND movingaverage = 0")
      metric_with_calculated_averages.first.attributes.each do |name, value|
        next if Metric.metadata.include?(name)
        next if Metric.groupbydata.include?(name)
          self.send(name+"=",value)
      end
    end
TODO remove the following methods
This method is used in the /metrics/:/:/cache route