From 0b64210ff436c4497d93961efec2d087158f08a1 Mon Sep 17 00:00:00 2001 From: andreagerino Date: Tue, 14 Jun 2016 12:32:22 +0200 Subject: [PATCH] Adding explorations endpoint --- .../invisiblepuzzle/invisiblepuzzle.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/routes/services/invisiblepuzzle/invisiblepuzzle.js b/routes/services/invisiblepuzzle/invisiblepuzzle.js index 347cc59..61df7c5 100644 --- a/routes/services/invisiblepuzzle/invisiblepuzzle.js +++ b/routes/services/invisiblepuzzle/invisiblepuzzle.js @@ -296,6 +296,49 @@ router.get('/explorations/hpbylevel', function(req, res, next) { }); +router.get('/sonifications/bylevel', function(req, res, next) { + + var collection = icarusDb.collection('resources'); + + var cursor = collection.aggregate( + + // Pipeline + [ + // Stage 1 + { + $match: { + "appdata.appname" : "Invisible Puzzle", + "userdata.event" : "exploration", + "debug" : false + } + }, + + // Stage 2 + { + $project: { + "identifier": { + "lvl": "$userdata.level.id", + "son": "$userdata.sonification" + } + } + }, + + // Stage 3 + { + $group: { + "_id": "$identifier", + "count": {$sum: 1} + } + } + + ] + + ); + + return_cursor(cursor, req, res, next); + +}); + function return_cursor(cursor, req, res, next){ cursor.toArray(function(err, result) { -- 2.18.1