AvalonMonoScripts/totalPendingPerUserOnVideosLessThan1Week.js
2021-09-08 14:14:22 +03:00

51 lines
881 B
JavaScript

mongo = require("./mongoHelp.js")
agg = [
{
'$sort': {
'ts': -1
}
},{
'$unwind': {
'path': '$votes',
'includeArrayIndex': 'string',
'preserveNullAndEmptyArrays': false
}
}, {
'$sort': {
'votes.u': 1
}
}, {
'$match': {
'votes.claimed': null
}
}, {
'$match': {
'ts': {
'$gt': Date.now()-604800000
}
}
}, {
'$group': {
'_id': {
'User': '$votes.u'
},
'claims': {
'$sum': '$votes.claimable'
}
}
}, {
'$sort': {
'claims': -1
}
}, {
'$limit': 10
}
]
mongo.aggregate('avalon5', 'contents', agg).then(res => {
res.forEach(element => {
element.claims=element.claims/100
console.log(element)
})
})