From d00d069744967ae7a441e8858092420da4bda986 Mon Sep 17 00:00:00 2001 From: mgerb42 Date: Fri, 16 Sep 2016 20:06:20 +0000 Subject: [PATCH] fixed end point ordering --- server/model/daily_sensor/daily_sensor.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/model/daily_sensor/daily_sensor.go b/server/model/daily_sensor/daily_sensor.go index 8fd03a0..0a80db1 100644 --- a/server/model/daily_sensor/daily_sensor.go +++ b/server/model/daily_sensor/daily_sensor.go @@ -233,6 +233,10 @@ func GetUniqueSensorDates(sensor_location string) ([]Years, error){ err := c.Pipe([]bson.M{bson.M{"$match": bson.M{"location": sensor_location}}, bson.M{"$group": bson.M{"_id": "$year", "months": bson.M{"$addToSet": bson.M{"month": "$month", "monthname": "$monthname"}}}}, bson.M{"$project": bson.M{"year": "$_id", "months": "$months"}}, + bson.M{"$unwind": "$months"}, + bson.M{"$sort": bson.M{"months.month": -1}}, + bson.M{"$group": bson.M{"_id": "$year", "months": bson.M{"$push": "$months"}}}, + bson.M{"$project": bson.M{"year": "$_id", "months": "$months"}}, }).All(&d)