Running leaderboard queries with a 'not in' clause
T
Toby Gladwell
started a topic
almost 8 years ago
Hi all,
I need to be able to run a leaderboard query that filters out a set of users that the player has already connected with. I can run a standard mongo query against a leaderboard collection through the portal as such :
But... I cannot find a way to do this in cloud code. It appears that Leaderboard collections are hidden behind Spark.getLeaderboards().getLeaderboard(<name>) without access to the underlying collection.
Any help here greatly appreciated!
Thanks,
- Toby
Best Answer
T
Tech Support
said
almost 8 years ago
ok, thanks for that.
We currently have an AroundMeLeaderboardDataRequest, but this is either everyone or just friends.
What I'd really like to do is add another options parameter to this call "excludeIds" which will do exactly what you need.
I'd need to schedule this, and we would be able to get it out in early April, is this acceptable?
If not, let me know as there are some other less clean approaches we could use.
This is a good question, it's not something thats been asked before.
Could you explain your use case a little further? What do you plan to do with these players once returned?
Gabriel
T
Toby Gladwell
said
almost 8 years ago
The use case is for matchmaking people to bring an ally with them into battle. After the battle, the ally can be added as a friend - a friend list that we manage in a collection containing a list per player. I'm using a single leaderboard that tracks all players by level to make the query.
So what I want to do is ideally select a window around the players level that includes up to <n> entries but excludes the players friends. The obvious solution i came up with was to simply select <n> + current friend count and let the client deal with existing friends. The downside is the query returning a larger than optimal set.
I'm guessing that redis or something similar is being used for the leaderboard system?
I hope my answer provides enough detail.
- Toby
Tech Support
said
almost 8 years ago
Answer
ok, thanks for that.
We currently have an AroundMeLeaderboardDataRequest, but this is either everyone or just friends.
What I'd really like to do is add another options parameter to this call "excludeIds" which will do exactly what you need.
I'd need to schedule this, and we would be able to get it out in early April, is this acceptable?
If not, let me know as there are some other less clean approaches we could use.
Gabriel
T
Toby Gladwell
said
almost 8 years ago
Yep - the current solution is to use the AroundMeLeaderboardDataRequest and just request an extra set that covers the potential of including friends. We can run with that for now and then use an exclusion method when it comes online. April is fine!
Toby Gladwell
Hi all,
I need to be able to run a leaderboard query that filters out a set of users that the player has already connected with. I can run a standard mongo query against a leaderboard collection through the portal as such :
{Level:{$gt:10}}, {userId:{$nin:[<userid>. ..., <userid>]}}
But... I cannot find a way to do this in cloud code. It appears that Leaderboard collections are hidden behind Spark.getLeaderboards().getLeaderboard(<name>) without access to the underlying collection.
Any help here greatly appreciated!
Thanks,
- Toby
ok, thanks for that.
We currently have an AroundMeLeaderboardDataRequest, but this is either everyone or just friends.
What I'd really like to do is add another options parameter to this call "excludeIds" which will do exactly what you need.
I'd need to schedule this, and we would be able to get it out in early April, is this acceptable?
If not, let me know as there are some other less clean approaches we could use.
Gabriel
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstTech Support
Hi Toby
This is a good question, it's not something thats been asked before.
Could you explain your use case a little further? What do you plan to do with these players once returned?
Gabriel
Toby Gladwell
The use case is for matchmaking people to bring an ally with them into battle. After the battle, the ally can be added as a friend - a friend list that we manage in a collection containing a list per player. I'm using a single leaderboard that tracks all players by level to make the query.
So what I want to do is ideally select a window around the players level that includes up to <n> entries but excludes the players friends. The obvious solution i came up with was to simply select <n> + current friend count and let the client deal with existing friends. The downside is the query returning a larger than optimal set.
I'm guessing that redis or something similar is being used for the leaderboard system?
I hope my answer provides enough detail.
- Toby
Tech Support
ok, thanks for that.
We currently have an AroundMeLeaderboardDataRequest, but this is either everyone or just friends.
What I'd really like to do is add another options parameter to this call "excludeIds" which will do exactly what you need.
I'd need to schedule this, and we would be able to get it out in early April, is this acceptable?
If not, let me know as there are some other less clean approaches we could use.
Gabriel
Toby Gladwell
Yep - the current solution is to use the AroundMeLeaderboardDataRequest and just request an extra set that covers the potential of including friends. We can run with that for now and then use an exclusion method when it comes online. April is fine!
Thanks Gabriel,
- Toby
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics