Problem with getUserRanking

0 votes
Let me explain the problem with getUserRanking in an example. Here are the scores of 5 players:

Player1 - 4

Player2 - 4

Player3 - 4

Player3 - 4

Player3 - 4

The call to getUserRanking() will return "1" for any user, because they all have the same score. In that way, I can't correctly use the method getTopNRankers() with offset, because I don't know what offset to set, as all players have the same ranking.

Is there a workaround for this issue?
closed with the note: Found another solution for the issue
asked Dec 4, 2014 in App42 Cloud API-BaaS by vladislav (10 points)
closed Dec 5, 2014 by vladislav
Will all your app users have same score? If that is the case, you will get the same result in leaderboard irrespective to offset and max parameter you will pass in the call. The only difference would be there in the leaderboard that they will have different time of score submission. You can arrange them based on the time they have submitted the score and ranked them accordingly at client side though.
Are you looking for the leaderboard to be generated only for particular score range instead of offset?
Users will have different scores, but there will definitely be situations where multiple users have the same score. You know, we want to put a button called "me" and it should scroll the leaderboard to users position. Unfortunately when you have multiple users with same score you can't identify the correct offset to pass to getTopNRankers().
If users are having same score, you have to give the priority to users based on some other criteria. For example in most of the games it is based on time of score submission. If you pass the offset as 10, you might get the same score of 10 different users. Now you have to think of the users to whom you have to give higher rank or you have to remove it from the leaderboard. If you want to discard all the users(which ideally should not be the case), you have to fetch next offset and do the same check again.
I understand but my task is a bit different I need to scroll in the leaderboard to the position where the user is present. If the user has a score of "10" and there are another 50 users with the same score, I can't identify the offset which I shall pass to the getTopNRankers() function.
So basically you wan to skip those users who have same score? Ideally you need an API to create leaderboard only for users who are less than that user score. Please confirm.
No, I don't want to skip them. Ideally I would like the function getTopNRankers() to return unique ranks for players with same score.
This looks like a pretty specific requirement and only way to achieve this to keep on fetching records until you get the next records with different score. You can use custom code to achieve this and put your logic there to fetch the next rankers whose score are less than the given user.
Let me know it makes sense.
That would be to costly in terms of massive amount of users.

We decided to implement our custom leaderboard using Storage service. All my requirements can be implemented using Storage service functions with queries and offsets.
Yes, this would be a wise solution to have. Many of our customers have already done this for their custom requirements.
Requesting you to please close the question if it is answered.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...