Displaying differences for changeset
 
display as  

src/java/m/timeseries/ApplicationConfig.java

@@ -40,8 +40,9 @@
         resources.add(csip.ReportService.class);
         resources.add(csip.UIService.class);
         resources.add(m.timeseries.aggregate.V1_0.class);
+        resources.add(m.timeseries.aggregate.V1_1.class);
         resources.add(m.timeseries.delete.V1_0.class);
-        resources.add(m.timeseries.insert.V1_0.class);
+    resources.add(m.timeseries.insert.V1_0.class);
     resources.add(m.timeseries.query.V1_0.class);
     }
 }

src/java/m/timeseries/aggregate/V1_0.java

@@ -5,6 +5,7 @@
  */
 package m.timeseries.aggregate;
 
+import com.mongodb.CommandResult;
 import com.mongodb.MongoClient;
 import com.mongodb.MongoClientURI;
 import com.mongodb.client.AggregateIterable;
@@ -30,6 +31,7 @@
 import java.util.Date;
 import java.util.List;
 import java.util.TimeZone;
+import org.bson.BsonDocument;
 import org.bson.Document;
 import org.bson.types.ObjectId;
 import org.bson.conversions.Bson;
@@ -162,27 +164,26 @@
   }
 
   private JSONObject getResult(MongoCollection<Document> c, Document locationDoc, Date startDate, Date endDate,
-          String aggregationLevel) throws JSONException {
-    /*
-    db.getCollection("bigdata test series").aggregate([
-    { "$match": { "location_id": "big_yearlychunks" } },
-    { "$unwind": "$data" },
-    { "$project": {
-        "tmin": { "$arrayElemAt": ["$data", 1] },
-        "month": { $month: { "$arrayElemAt": ["$data", 0] } },
-        "year": { $year: { "$arrayElemAt": ["$data", 0] } },
-    } },
-    { "$group": {
-        "_id": { month: "$month", year: "$year" },
-        "tmin_avg": { "$avg": "$tmin" },
-        "tmin_min": { "$min": "$tmin" },
-        "tmin_max": { "$max": "$tmin" },
-        "month": { "$first": "$month" },
-        "year": { "$first": "$year" },
-    } },
-    { "$sort": { "year": 1, "month": 1 } },
-    ])
-    */
+          String aggregationLevel) throws JSONException, ServiceException {
+    String testJS = "db.getCollection(\"bigdata test series\").aggregate([" +
+"    { \"$match\": { \"location_id\": \"big_yearlychunks\" } }," +
+"    { \"$unwind\": \"$data\" }," +
+"    { \"$project\": {" +
+"        \"tmin\": { \"$arrayElemAt\": [\"$data\", 1] }," +
+"        \"month\": { $month: { \"$arrayElemAt\": [\"$data\", 0] } }," +
+"        \"year\": { $year: { \"$arrayElemAt\": [\"$data\", 0] } }," +
+"    } }," +
+"    { \"$group\": {" +
+"        \"_id\": { month: \"$month\", year: \"$year\" }," +
+"        \"tmin_avg\": { \"$avg\": \"$tmin\" }," +
+"        \"tmin_min\": { \"$min\": \"$tmin\" }," +
+"        \"tmin_max\": { \"$max\": \"$tmin\" }," +
+"        \"month\": { \"$first\": \"$month\" }," +
+"        \"year\": { \"$first\": \"$year\" }," +
+"    } }," +
+"    { \"$sort\": { \"year\": 1, \"month\": 1 } }," +
+"])";
+    
     List<String> header = (ArrayList) locationDoc.get("header");
     List<List<Object>> filtered = new ArrayList();
 
@@ -195,7 +196,7 @@
             new Document("$group", groupData(header)),
             sort(new Document("year", 1).append("month", 1))
     );
-            
+    
     AggregateIterable<Document> iter = c.aggregate(aggList).allowDiskUse(true);
     for (Document d : iter) {
         List<Object> row = new ArrayList<>();

test/service_tests/m/aggregate/big_data/aggregate-monthly-req.json

@@ -14,7 +14,7 @@
             "value": "2001-01-01"
         }, {
             "name": "end_date",
-            "value": "2002-01-01"
+            "value": "2002-12-31"
         }, {
             "name": "aggregation_level",
             "value": "monthly"