daily pastebin goal
25%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def five_minute_prices
  2.       time = Time.zone.now.end_of_day
  3.       first_price = Price.first.created_at
  4.       prices = {}
  5.  
  6.       while first_price < time
  7.         earlier_time = time - 300
  8.         later_time = time
  9.         prices[time] = []
  10.         r = Range.new(earlier_time, later_time)
  11.         Price.all.each do |price|
  12.           prices[time] << price if r.cover?(price.created_at)
  13.         end
  14.         time -= 300
  15.       end
  16.       prices.reject { |key,value| value.empty? }
  17.     end
RAW Paste Data
Top