I'm trying to calculate average speed of data for 15 minutes. I get the result back, it contains average speed, but not sure it's correct and for 15 minute sets, also minutes
is nil.
o3 := bson.M{
"$group": bson.M{
"_id": bson.M{
"minute": bson.M{
"$subtract": []interface{}{
"$timestamp",
bson.M{
"$mod": []interface{}{
"$minute",
15,
},
},
},
},
},
"averageSpeed": bson.M{
"$avg": "$speed",
},
},
}
Anyone done something similar or can help?
EDIT: $timestamp field is ISODate format and Date type
Thank you