-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Hi Ben
I am currently looking at the server scripts and I have a question regarding playerlevel rating. In the playerslevel.list function, there is an option to sort levels by player ratings that seems to sort levels using a "rating" field:
switch(options.mode) {
case "alltime":
case "popular": // legacy
query.sort = "-rating";
break;
.....
However, levels do not have a rating field (only a ratings one wich is an array) so I do not really understand how it is supposed to work (I am new to mongoDB thouth so maybe there is a subtility I do not understand). Looking at the playerlevels objects structure in mongodb, I would say the alltime rating can only be obtained doing: score/votes
Also, when retrieving player levels with the api, wich field of the returned level object should I look at to get the alltime rating? (is there a rating field return or should I do score/votes?)
Finnaly, I found a bug in the playerlevels.list script. In the rate function, you must change the line
db.PlayerLevel.findOneAndUpdate({_id: doc._id}, doc, { upsert: false }, function(error) {
var docid = doc._id;
delete doc._id;
db.PlayerLevel.findOneAndUpdate({_id: docid}, doc, { upsert: false }, function(error) {
else mongoose return an eror saying: MongoError Mod on _id not allowed