How can I create active relation queries in Rails 3 that are aggregated by time slice?
I'd like to build queries that for every n minute interval can return min, max, avg, sum, count, for every sample of a counter with a particular name.
create_table "samples"
t.integer "counter_id"
t.string "name"
t.float "value"
t.datetime "created_at"
end
Unfortunately I've never used Postgres, so this solution works in MySQL. But I think you can find out Postgres analogs.
Usage
etc
This should do the trick:
You can also swap average for any of minimum, maximum and sum.