How to implement relative leaderboard

+1 vote
Hey guys,

I want to inplement a relative leaderboard, which means treat current user as the middle point and find 5 users have higher ranking than me and 5 users have lower ranking to me.

I didn't find method that allow me to do that directly, nor the method can use to retireve user based on his/her ranking.

I don't want to implement this in a way that get top 20 first and then get sublist of the top 20. This is not scale and will be very slow for the user who has a low ranking. Any one has any idea about how to achieve relative leaderboard?

Thanks in advance.
asked May 22, 2014 in App42 Cloud API-BaaS by tianyi (15 points)

1 Answer

+1 vote

hi tianyi ,

 We have method to find user ranking directly , you can find code snippet here

answered May 22, 2014 by samita.mahajan (60 points)
What I am looking for is the other way around. By giving a ranking, find the user who has this ranking. Is there a way to do this?
Hi, Yes, I understand your use case, You can achieve this by using our leaderboard service. Let say if you know the current user ranking by using our method ( http://api.shephertz.com/app42-docs/leaderboard-service/#get_user_ranking )and based on this you can find the highest rankers and lower rankers then you by using our offset supported methods something like this.

scoreBoardService.setPageOffset(45);// Suppose your rank is 50 .So you must set your offset value is 45 .
Game getTopRanker = scoreBoardService.getTopNRankers(gameName, 5);
Thanks Samita!
When I call getTopNRankers and game.getScoreList().get(i).getRank(), I can get other data, but for rank, it always return null. I also tried getTopNRankings, and got the same result. Any hint for this?
Hi,
1) Rank is only coming in getUserRanking method.
2) getTopNRankers or getTopNRankings is coming in rank order.If you want to maintain the rank of users , you add offset no. and current index no. then you get the exact rank of users also.
E.g : Your friend index is 1 then rank is 45(offset)+ 1 = 46 (Friend Rank)
Is it possible that this setPageOffset() function isn't working correctly in the ActionScript API?  I can seem to get anything but the top of the leaderboard.  My code:

var scoreBoardService:ScoreBoardService = serviceAPI.buildScoreBoardService();
scoreBoardService.setPageOffset( 6 );
scoreBoardService.getTopNRankers( "highscores", 6, response );

Is there something else I need to do?  I tried calling setPageMaxRecords( 1 ), but that didn't seem to make a difference.
Hi Shane,
Kindly find the latest sdk of ActionScript API and let me know if it helps.
https://github.com/shephertz/App42-ActionScript-SDK
Thanks.
Yes, thank you for making version 2.4.1, that has fixed it!
How do we know which are the "offset supported methods"?
And for example if I use SetPageMaxRecords(N) and then getTopNRankings, "game", M), will it return N or M or max(N,M), or min(N,M) results?
Hi Jorge Galvão ,
1)These are list of supported methods in which we support offset value and we also mention in our documents as soon as possible :-
Get Top N Rankings
Get Top N Rankers
Get Top N Rankers By Date
Get Top N Rankers By Group
Get Top N Rankers From Facebook
Get Top N Rankers From Facebook With Date Range
Get Top N Target Rankers
2)SetPageMaxRecords(N) and then getTopNRankings("game", M), It will always return M because M is passed from the method.
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
...