Commit 5bae4b56 authored by andreagerino's avatar andreagerino

Adding explorations endpoint

parent 9f22d44c
......@@ -114,6 +114,55 @@ router.get('/users/sighted', function(req, res, next) {
});
router.get('/explorations/headphones', 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
{
$group: {
"_id" : 1,
"explorations" : {
"$sum" : 1
},
"with_hp" : {
"$sum" : {
"$cond" : [
{
"$eq" : [
"$userdata.headphones",
true
]
},
1,
0
]
}
}
}
}
]
);
return_cursor(cursor, req, res, next);
});
function return_cursor(cursor, req, res, next){
cursor.toArray(function(err, result) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment