Retrieve A Subset Of A Leaderboard

Hi there,

In Corona Cloud, is it possible to request only a subset of a leaderboard, e.g., by specifying a score range or list of users?  It seems like the Retrieve Scores API takes only one parameter, the leaderboard, and it returns the entire leaderboard.  If there are a lot of users, that could end up being a whole lot of data to pass over a slow network connection.

It would probably also make sense if there were APIs for things like getting a player’s rank on a leaderboard and getting the total number of players on a leaderboard.  It seems to me that it would be more efficient to process those requests on the server side and pass the result (a small amount of data) over the network connection, instead of passing the entire leaderboard over the network connection (potentially a large amount of data) and having the client process it.

Thanks!

  • Andrew

Hi aukStudios, these are great points, and I have already added them to the items that need to be done by the team ASAP.

I will update this forum post, as soon as they are deployed into production.

I will do my best to get as many of the items you mentioned done.

Thanks for the feedback.

-Mohamed

Thanks Mohamed, sounds great!

  • Andrew

Hi Mohamed,

One other thought occurred to me that you may want to pass on to your team – in addition to retrieving a subset of a leaderboard based on a set of usernames or a score range, it would also make sense to be able to retrieve them based on rank range, i.e., retrieve the top X players on the leaderboard, or the players who are within X ranks from a given rank.

It would be cool if the API were designed to allow all of the filters in combination.  I could see the API accepting five filter parameters, all optional: a table of usernames, a min score, a max score, a min rank, and a max rank.  The results would be restricted to meet those criteria.  If none are specified, it’ll behave just like the current API and return the entire leaderboard.

Thanks!

  • Andrew

Hi Andrew,

Thanks, I’ve added it to the enhancements list for leaderboards.

-Mohamed

Hi Mohamed.  It seems every day I think about this topic more and have another idea to share.  :-)  This time, I thought I’d describe the full use case I have in mind (which probably applies to other developers too), why I think it’s unfortunately impractical to do with the current APIs, and some ideas how to make it practical.

The use case is to have users register to Corona Cloud only through the facebook method, not via the email/username/password method, and then to display leaderboards showing just the current user and their facebook friends who use the app.

My understanding is that showing a leaderboard with just the current user and their facebook friends who use the app would be impractical to implement with the current APIs.  I think it would have to go something like this, the first two steps being the impractical ones:

  1. Retrieve the entire leaderboard (a potentially impractically large file, since it’ll contain data on all users who’ve ever submitted a score).  This will return a table with the Corona Cloud user_id for each user in the leaderboard
  2. For every user_id from step 1, retrieve that user’s profile (a potentially enormous and impractical number of network calls; also, this API appears to be missing from corona-cloud-core).  This will give us their facebook_id
  3. Retrieve the user’s facebook friends, either through facebook directly or through the cloud API.  (If through facebook directly, the facebook graph API let’s you see which users have installed the app using the “installed” field, which is handy)
  4. Cross-reference the facebook friend IDs from step 3 with the facebook_id’s from step 2 to get the scores for just the current user’s facebook friends

If I’m missing an easier way to accomplish this using the current APIs, I’d be very interested to hear!

Meantime, here are some ideas of how to make this practical:

  • In step 1, the results set from the leaderboard could/should include the facebook_id for each user, if available.  That would eliminate the need for step 2 (which is by far the most expensive step)
  • In step 1, allow the API to accept filter criteria for retrieving a subset of the leaderboard, like I mentioned above.  I mentioned filtering by score range, rank range, and list of user_id’s.  It could also filter by list of facebook_id’s

If both of these were implemented, the whole process would become very practical.  One would retrieve the current user’s facebook friends who have the app installed through facebook (using the “installed” field in the graph API), request the leaderboard scores for just those individuals using their facebook_id’s (a small and practical number), and get a results set (also small) from Corona Cloud that included each user’s facebook_id as a field (allowing one to cross-reference back to any other info from facebook).

Of course, there could also be a single convenience API that does this all in one step (since Corona Cloud gets the facebook auth token).  But I think it’s pretty compelling to give developers a leaderboard API with flexible filter criteria so that it can cover a whole range of use cases besides just this one.

Thanks!

  • Andrew

Hi aukStudios, these are great points, and I have already added them to the items that need to be done by the team ASAP.

I will update this forum post, as soon as they are deployed into production.

I will do my best to get as many of the items you mentioned done.

Thanks for the feedback.

-Mohamed

Thanks Mohamed, sounds great!

  • Andrew

Hi Mohamed,

One other thought occurred to me that you may want to pass on to your team – in addition to retrieving a subset of a leaderboard based on a set of usernames or a score range, it would also make sense to be able to retrieve them based on rank range, i.e., retrieve the top X players on the leaderboard, or the players who are within X ranks from a given rank.

It would be cool if the API were designed to allow all of the filters in combination.  I could see the API accepting five filter parameters, all optional: a table of usernames, a min score, a max score, a min rank, and a max rank.  The results would be restricted to meet those criteria.  If none are specified, it’ll behave just like the current API and return the entire leaderboard.

Thanks!

  • Andrew

Hi Andrew,

Thanks, I’ve added it to the enhancements list for leaderboards.

-Mohamed

Hi Mohamed.  It seems every day I think about this topic more and have another idea to share.  :-)  This time, I thought I’d describe the full use case I have in mind (which probably applies to other developers too), why I think it’s unfortunately impractical to do with the current APIs, and some ideas how to make it practical.

The use case is to have users register to Corona Cloud only through the facebook method, not via the email/username/password method, and then to display leaderboards showing just the current user and their facebook friends who use the app.

My understanding is that showing a leaderboard with just the current user and their facebook friends who use the app would be impractical to implement with the current APIs.  I think it would have to go something like this, the first two steps being the impractical ones:

  1. Retrieve the entire leaderboard (a potentially impractically large file, since it’ll contain data on all users who’ve ever submitted a score).  This will return a table with the Corona Cloud user_id for each user in the leaderboard
  2. For every user_id from step 1, retrieve that user’s profile (a potentially enormous and impractical number of network calls; also, this API appears to be missing from corona-cloud-core).  This will give us their facebook_id
  3. Retrieve the user’s facebook friends, either through facebook directly or through the cloud API.  (If through facebook directly, the facebook graph API let’s you see which users have installed the app using the “installed” field, which is handy)
  4. Cross-reference the facebook friend IDs from step 3 with the facebook_id’s from step 2 to get the scores for just the current user’s facebook friends

If I’m missing an easier way to accomplish this using the current APIs, I’d be very interested to hear!

Meantime, here are some ideas of how to make this practical:

  • In step 1, the results set from the leaderboard could/should include the facebook_id for each user, if available.  That would eliminate the need for step 2 (which is by far the most expensive step)
  • In step 1, allow the API to accept filter criteria for retrieving a subset of the leaderboard, like I mentioned above.  I mentioned filtering by score range, rank range, and list of user_id’s.  It could also filter by list of facebook_id’s

If both of these were implemented, the whole process would become very practical.  One would retrieve the current user’s facebook friends who have the app installed through facebook (using the “installed” field in the graph API), request the leaderboard scores for just those individuals using their facebook_id’s (a small and practical number), and get a results set (also small) from Corona Cloud that included each user’s facebook_id as a field (allowing one to cross-reference back to any other info from facebook).

Of course, there could also be a single convenience API that does this all in one step (since Corona Cloud gets the facebook auth token).  But I think it’s pretty compelling to give developers a leaderboard API with flexible filter criteria so that it can cover a whole range of use cases besides just this one.

Thanks!

  • Andrew

This topic has gone quiet so maybe was picked up on a different thread?   I have exactly the same use case which is groups of people that know each through facebook that I want to “compete via leader board” with each other.  I don’t really have use for a global leaderboard.  Andrews comments above are spot on.  if I could request leaderboard scores by passing in a list of facebook and/or userid’s I would be set. 

Any plan on when this capability might be implemented?  Thanks so much, this is a major feature for my app.

Plus one for me–retrieving the player’s rank and a subset of the leaderboard that would include a particular player.  For instance if I set page size to ten and then retrieve the page that contains user_id x.

This topic has gone quiet so maybe was picked up on a different thread?   I have exactly the same use case which is groups of people that know each through facebook that I want to “compete via leader board” with each other.  I don’t really have use for a global leaderboard.  Andrews comments above are spot on.  if I could request leaderboard scores by passing in a list of facebook and/or userid’s I would be set. 

Any plan on when this capability might be implemented?  Thanks so much, this is a major feature for my app.

Plus one for me–retrieving the player’s rank and a subset of the leaderboard that would include a particular player.  For instance if I set page size to ten and then retrieve the page that contains user_id x.