-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
get PlayerLevel rating? #14
Comments
Hi Ramse, The ratings are stored in array that counts each vote for each value:
Additionally the last 100 individual ratings are stored with its average:
From that array you can calculate the all time:
You can also access the
Thanks for the report, do you know how to do a pull request? If you don't I'll take care of it but if you've already made the change you can submit it and have it patched straight in. |
Hi Ben Well, I do not have exactly the same structure as you mentionned. Indeed, the ratings array has this structure for me:
So it looks like it is storing average votes for each day (I don't know the reason for this, seems pretty useless but there might be a good reason...) I also have a ratingaverages array but wich is empty...
Also, my question was how did the ordering by rating works as, in the code, the query seems to use a "-rating" sort tag. So, as I understand it, it rely on a "rating" field to do the sorting. But there is no such field in my playerlevel objects (only a ratings field wich is an array of array) so I don't know how it is supposed to work... Finally, concerning the pull request, I will let you do the change as I already made some personnal changes in the playtomic server source code to suit my own personnal needs. |
You can calculate the rating using votes and score. Here's how to get a percentage. Math.floor(((_data.levels[i].score / _data.levels[i].votes) / 10) * 100)+'% Liked'; I'm not clear exactly the question, if you want a sorted list set the mode property using one of following strings. newest, last7daysaverage, last30daysaverage, alltime We have also heavily modified the original, so some of this may be slightly off. |
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
The text was updated successfully, but these errors were encountered: