Reputation: 23
I'd like to group and average on dynamic time intervals. Similar question to: Grouping into interval of 5 minutes within a time range.
Right now, I am using the query:
r.db('windMachine').table('stats3')
.between(r.time(2015, 5, 7, 18, 0, 0, "Z"), r.time(2015, 5, 7, 24, 0, 0, "Z"), {index: "date"})
.group([r.row("date").hours(), r.row("date").minutes()])
.avg("TMP0")
Which returns:
[
{
"group": [
21,
2
],
"reduction": 22.802153846153846
},
{
"group": [
21,
3
],
"reduction": 22.6628
},
{
"group": [
21,
4
],
"reduction": 22.384324324324318
}
]
I'd like to group this further, down into 5 minute (or other) intervals. What is the best way to go about doing this?
Upvotes: 2
Views: 462
Reputation: 608
I actually met a similar problem and here is what I did:
.group(r.row('date').toEpochTime().sub(r.row('date').toEpochTime().mod(<INTERVAL_IN_SECONDS>))
What this do is to group time by <INTERVAL_IN_SECONDS>
I don't know if this is the best way for the task but it works for me.
Upvotes: 2