Skip to content

Instantly share code, notes, and snippets.

@gregblake
Created January 11, 2018 17:10
Show Gist options
  • Select an option

  • Save gregblake/099f598fc762990763a377050bb1e1bc to your computer and use it in GitHub Desktop.

Select an option

Save gregblake/099f598fc762990763a377050bb1e1bc to your computer and use it in GitHub Desktop.
device_locations
def some_name(device_locations:)
data = []
0.upto(12).each do |i|
data << device_locations.was_located_between(shift_right: i.hours, shift_left: (i+1).hours).count
end
data << device_locations.where(located_at:((Time.zone.parse('1970-01-01')).utc)..(13.hours.ago.utc)).count
data.join(",")
end
data = [some_name(device_locations: @device_locations)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment