question

ding avatar image
ding asked

Get custom time based leaderboard result

In our game we want to implement a time based leaderboard, we want to get the highest score in the last hour. We can not use hourly resettable leaderboard as we want the result exactly to be in the last hour of the realtime. I wonder how can we achieve this using Playfab?

One solution we can think of is to use the hourly resettable leaderboard, and get the date from current version and pervious version and filter the merged data. However there is no API to get the result of the previous version of the leaderboard, also there is no way to get the time stamp for the user record.

Thanks.

Leaderboards and Statistics
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

If I understand your question, it sounds like what you're asking for is a way to have the highest score each player achieved in a single leaderboard, with each player's scores being invalidated after one hour. So, if player A scored 26 points 30 minutes ago, but 31 points 50 minutes ago, his score on the leaderboard would be 31 for the next ten minutes, then drop to 26. And then if he doesn't play for another 30 minutes, he would be removed from the leaderboard. In other words, tracking on multiple scores per player, with a timestamp for each individual score, invalidating any score over a certain age, and being able to query for the highest non-expired score across all players in a single leaderboard.

Currently, our leaderboards support complex aggregation (so, you could set it to Max, so that only the highest score reported per player is kept) and resets (as you described - UTC based). We will be providing more complex leaderboard behaviors in an upcoming release, though I'm not certain we'll be able to support something with those specific requirements. If you need this right away, I would recommend using an external data table to track the scores and timestamps. You can access any Web API enabled database via Cloud Script, providing you with a way to ensure this remains a secure update in your game, to help prevent cheating.

4 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.

ding avatar image ding commented ·

Hi Brendan,

Thanks for answering the question. Sorry, i didn't make myself clear enough. The behaviour we want is to get the highest score from last 60 minutes. For example. if the player get 26 points 30 minutes ago, but 31 points 50 minutes ago, we won't send 26 point to the playfab as in the latest 60 minutes 31 point is the highest score from the local play. However 10 minutes later, as the 31 points invalid, we will send another now score that player get. So "Last" aggregation would meet our requirement.

However the api we are expecting is that we can use "StartTime" and "EndTime" as a parameter in function "GetLeaderBoard", so we can get the leaderboard result filtered by timestamp of the point being sent.

0 Likes 0 ·
brendan avatar image brendan ♦♦ ding commented ·

Does this effectively summarize what you're asking, then?

  • Max aggregation (always only taking the highest score reported)
  • For each row (individual player score), store a timestamp and if it is more than one hour old, remove it

Or is it this?

  • If the last reported score for the player is more than an hour old, write the new score
  • If the last reported score for the player is less than an hour old, only update if the new score is higher
  • For each row (individual player score), store a timestamp
  • Add a get leaderboard call which takes a start and end time, and filters the list returned to that window (so, if you specify 8-9pm yesterday, anyone who has posted a score today would not appear on the leaderboard queried)

At the moment, we do not support either of these, but I'd like to make sure I capture your specific scenario, so that I can have that in the backlog for consideration as we work on our leaderboard update. In the near-term, I would still recommend using an external data table for this.

0 Likes 0 ·
ding avatar image ding commented ·

Here what we expect from the API, and we believe other developers can benefit from it as well.

  • For each row (individual player score), store a timestamp
  • Add a get leaderboard call which takes a start and end time, and filters the list returned to that window (so, if you specify 8-9pm yesterday, anyone who has posted a score today would not appear on the leaderboard queried)

We can handle the update logic in the client.

0 Likes 0 ·
brendan avatar image brendan ♦♦ ding commented ·

I'm not certain the updated leaderboard system will support that, as that usage pattern hasn't come up in any discussions with developers to date (until now, that is). That said, I'm adding it to the backlog for the leaderboard work, for consideration by the engineering team.

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.