Nakama leaderboard filter by region

Greetings!

I have a question about Nakama leaderboards.

Can I query leaderboards on runtime? For example, if I want to let the user see 1-day, 3-day, 1-week and 1-month leaderboard, can it be done using one leaderboard on the server? Or do I have to create a separate leaderboard for each configuration?
Because if I have 1 property with 3 possible values, that’s 3 configurations. But if I have 2 properties with 3 possible values each, that’s 9 configurations. I’m afraid that this might be heavy on the storage.

Any help is appreciated.

Welcome @codedrunk!

Can I query leaderboards on runtime?

You can find the server runtime with all functions available for leaderboards in the docs:

https://heroiclabs.com/docs/runtime-code-function-reference/#leaderboards

For example, if I want to let the user see 1-day, 3-day, 1-week and 1-month leaderboard, can it be done using one leaderboard on the server? Or do I have to create a separate leaderboard for each configuration?

You want the player to see their scores over 1-day, 3-day, 1-week, and 1-month as a point in time score they achieved? or do you want to see a reset schedule on the score for that player over those time periods?

I think more detail on the game design would help determine the best way to handle it.

Because if I have 1 property with 3 possible values, that’s 3 configurations. But if I have 2 properties with 3 possible values each, that’s 9 configurations.

What does this mean? What is “1 property with 3 possible values”? It would help if you could use terminology that’s common to leaderboards like scores and records.

I’m afraid that this might be heavy on the storage.

This would NOT be heavy on storage. The leaderboard system we’ve built is designed to support 1000s of leaderboards and millions of records. The size of the datasets does not limit the scalability of the design. You can look at the codebase to review the performance of the code yourself.

1 Like

Let’s me explain using candy crush as an example. It has 5600 levels right now. Each level has a separate leaderboard. It also looks like they show you the leaderboard based on your region. So there are two properties of a leaderboard here: level and region. Level has 5600 possible values (and increasing). Region has 4000+ possible values if it’s a city. Now if I were to make a separate leaderboard for each level/region pair, that would be 22,400,000 leaderboards. Also, every time a user changes his region, i’ll have to move his records to different leaderboards. Is this approach fine to use in Nakama?

1 Like

That number of leaderboards will be fine if you give the server the appropriate resources. You should test with your specific workload to be sure you get the results you expect.

I’d also say check if you need these combinations of leaderboards, for example make sure city-level leaderboards are compelling for your audience and worth implementing.

Alright, thanks!

I read document that link but can not find any example. Can you explain more detail or give an example of filtering leaderboard by region?

Leaderboard seem have no filter funtion.You may try to create seperate leaderboard of different region as discuss above