Bigger batch and d/u vote comp for all users
This commit is contained in:
parent
7bdc56e2b2
commit
07da9675aa
58
downvoteEarnedvsUpvoteEarned.js
Normal file
58
downvoteEarnedvsUpvoteEarned.js
Normal file
@ -0,0 +1,58 @@
|
||||
mongo = require("./mongoHelp.js")
|
||||
approx = require("approximate-number")
|
||||
|
||||
|
||||
dAgg = [
|
||||
{
|
||||
'$unwind': {
|
||||
'path': '$votes',
|
||||
'includeArrayIndex': 'string',
|
||||
'preserveNullAndEmptyArrays': false
|
||||
}
|
||||
}, {
|
||||
'$match': {
|
||||
'votes.vt': {
|
||||
'$lt': 0
|
||||
}
|
||||
},
|
||||
},{'$limit': 10000},
|
||||
]
|
||||
|
||||
uAgg = [
|
||||
{
|
||||
'$unwind': {
|
||||
'path': '$votes',
|
||||
'includeArrayIndex': 'string',
|
||||
'preserveNullAndEmptyArrays': false
|
||||
}
|
||||
}, {
|
||||
'$match': {
|
||||
'votes.vt': {
|
||||
'$gt': 0
|
||||
}
|
||||
},
|
||||
|
||||
},{'$limit': 10000},
|
||||
]
|
||||
dClaimed = 0
|
||||
dVt = 0
|
||||
mongo.aggregate('avalon5', 'contents', dAgg).then(res => {
|
||||
res.forEach(element => {
|
||||
dClaimed = dClaimed+element.votes.claimable
|
||||
dVt = dVt+(element.votes.vt*-1)
|
||||
})
|
||||
console.log("Down, ",dVt,dClaimed/100,(dClaimed/100)/dVt)
|
||||
console.log("Down aprox, ",approx(dVt),approx(dClaimed/100))
|
||||
})
|
||||
|
||||
|
||||
uClaimed = 0
|
||||
uVt = 0
|
||||
mongo.aggregate('avalon5', 'contents', uAgg).then(res => {
|
||||
res.forEach(element => {
|
||||
uClaimed = uClaimed+element.votes.claimable
|
||||
uVt = uVt+(element.votes.vt)
|
||||
})
|
||||
console.log("Up, ",uVt,uClaimed/100,(uClaimed/100)/uVt)
|
||||
console.log("Up aprox, ",approx(uVt),approx(uClaimed/100))
|
||||
})
|
@ -35,7 +35,7 @@ exports.getUnique = getUnique
|
||||
function aggregate(db,collection,agg){
|
||||
const client = new MongoClient(url, options)
|
||||
client.connect()
|
||||
return client.db(db).collection(collection).aggregate(agg).batchSize(10000000000000).maxTimeMS(1000000).toArray().then((value) =>{client.close();return value})
|
||||
return client.db(db).collection(collection).aggregate(agg).batchSize(1).maxTimeMS(1000000).toArray().then((value) =>{client.close();return value})
|
||||
}
|
||||
|
||||
exports.aggregate = aggregate
|
||||
|
Loading…
Reference in New Issue
Block a user