Skip to content

get PlayerLevel rating? #14

@ramsestom

Description

@ramsestom

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions