Hi there -
I will be adding leaderboards in an upcoming release for my Unity-powered mobile title. We expect each leaderboard to have 1,000+ entries (essentially, one for every user to have submitted a particular statistic). The above means that we need some sort of a solution for retrieving and presenting leaderboard data in a way that is mobile-friendly, does not cause performance issues on the device, and does not trigger excessive PlayFab queries.
The solution I'm leaning towards is something like this:
- On opening the leaderboard, the user is automatically redirected to their own location on it (GetLeaderboardAroundUser).
- Since we're talking mobile performance, I'd like to keep it to 20 entries per page, so I'd limit the result size to 20 entries (there are workarounds for that limit, but I'm not sure how much sense they'd make in the long run - see below)
- The user always has the option to go to the first page of the leaderboard (GetLeaderboard, StartPosition = 0, MaxResults = 20).
- On any given page, the user has the option of going to the previous page (GetLeaderboard, StartPosition = currentPosition - 20, MaxResults = 20) or the next page (GetLeaderboard, StartPosition = currentPosition + 20, MaxResults = 20)
In the above solution, a fresh GetLeaderboard call will be made every type the user flips pages, goes to their own page, or to the current page.
Is this excessive? I was wondering if there is a caching solution of some kind, but since GetLeaderboard results are anyway limited to 100, it seems that navigating any leaderboard with 100+ entries would involve repeated queries to PlayFab.
Another alternative is to make each leaderboard page 100 entries long (that is, the maximum amount of entries that I can get per request). In theory, this could reduce the frequency of leaderboard queries (as there would be fewer pages in total); in practice, this advantage would probably disappear with more users (if I have 10,000 leaderboard entries, I still have 100 pages to go through).
If absolutely and truly necessary, I suppose I could look into a solution that builds up a cached leaderboard as the user flips through the pages (e.g., every time they query a page, it gets cached). I could then limit the user to only refreshing the data of that particular leaderboard every so often. However, that would be a bit complex from the coding standpoint (can be done, but certainly far less straightforward than relying on the GetLeaderboard query)