question

glen avatar image
glen asked

Leaderboard NextReset not match Version

I'm tying to figure something out which involves Leaderboard data upon reset. We use Leaderboards to manage seasons in our game via the reset frequency. When the game is open and the season ends the game waits X seconds and then attempts to query the leaderboard's previous version. This is so we can see who won the last season, or in other words, the season which just ended. We've had some issues with this querying too far back and throwing an exception. So to manage this issue we query the existing leaderboard Version first and then use that Version-1 to get the previous version. However this can still cause an issue because the leaderboard Version doesn't seem to increment immediately when the NextReset time is reached, I'm not sure what the timeframe on that is. So to manage that issue we also check the existing leaderboard's NextReset time to see if it's in the past. If it is then we know that using existing leaderboard Version-1 would query a leaderboad version too far back throwing an exception. Unfortunately this doesn't work because the leaderboard Version and NextReset don't seem to line up in this scenario. The NextReset seems to update immediately while the Version doesn't. Example:

Before reset:

Leaderboard.Version = 9, Leaderboard.NextReset = Tuesday

Shortly after reset:

Leaderboard.Version = 9, Leaderboard.NextReset = Wednesday

Expected (Shortly after reset):

Leaderboard.Version = 10, Leaderboard.NextReset = Wednesday

or

Leaderboard.Version = 9, Leaderboard.NextReset = Tuesday

And of course, eventually once leaderboard updating/archiving is complete:

Leaderboard.Version = 10, Leaderboard.NextReset = Wednesday

In the above example trying to query version 8 would throw an exception because it would be 2 leaderboard versions back, not 1, even though the existing version is showing 9. This would be fine, except we can't accommodate for this because the NextReset doesn't match up with the Version.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

So, the issue you're encountering is due to the fact that the data on the player statistic version is cached, while the next reset is calculated. And when the player statistic resets, it's going to take a short period (up to a minute) for all caches to be updated. Since there will always be a non-zero time for caches to update, and the key is going to be knowing whether the version you're looking at is the one that just expired or just started, the thing to do is to use GetPlayerStatisticVersions. You could either query that at some point after login, so that you have the info on the start and scheduled end times of the statistic, or you could just use it as a "safety check" if the operation described above is taking place during the range of reset time to reset time plus a couple of minutes (to be safe).

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

glen avatar image glen commented ·

If the player doesn't register a statistic for multiple versions in a row will GetPlayerStatisticVersions still return reliable information for the current version of the leaderboard?

0 Likes 0 ·
glen avatar image glen commented ·

Nevermind, I see how it works now. GetPlayerStatisticVersions is a separate concept from GetPlayerStatistics

0 Likes 0 ·
brendan avatar image brendan glen commented ·

Correct - the GetPlayerStatisticVersions call is "get me the version info for the title's player statistics", where GetPlayerStatistics is "get me the stats for this player".

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.