[AS3] Issue with Fetch Additional data in leaderboard

0 votes
Step to reproduce:
1/ Save 3 scores using "Saving additional Data along with Score" service.
Acctually that now I have 3 records:
  1. Score 10 with additonal json {name: "John", age: "30"}
  2. Score 11 with additonal json {name: "Foo", age: "25"}
  3. Score 15 with additonal json {name: "Bar", age:"18"}
2/ Now I start use "Fetch Additional data in leaderboard" service
var gameName:String="MyGame";  
var max:int= 5;  
var key1:String = "name";  
var value1:String = "John";  
var query:Query = QueryBuilder.build(key1, value1, Operator.EQUALS);  
scoreBoardService.setQuery( "MyCollectioname", query); 
scoreBoardService.getTopNRankers(gameName, max , new callback());
I expected the result was only one record of user named John, but actually all 3 three records returned!??
Our game is now feature on Apple store using App42 services, that's a good decision we made. We are deloping the next version and face this issue, please support us. Thank App42 team.
edited: change from scoreBoardService.setQuery( "MyDocument", query);  to scoreBoardService.setQuery( "MyCollectioname", query); to make it clear.
asked Oct 30, 2014 in App42 Cloud API-BaaS by Mai Khánh (12 points)
edited Nov 3, 2014 by Mai Khánh

1 Answer

–1 vote

Hello Mai,

GetTopNRankers with query will first get top N rankers and then fetch the additional data of users who are there in the leaderboard. It is not going to work in reverse as you stated. If you want to fetch record only for John user, you can fetch it separately using Storage Query. See here for details for the same.

Let me  know if it helps.


Himanshu Sharma

answered Oct 30, 2014 by hs00105 (2,005 points)
Thanks for your answer. But I think that's not correct for my case.

You can read the method's description at the link below.


Fetch Additional data in leaderboard: "Fetches leaderboard along with additional data of user in JSON format. One can pass query object while fetching desired records of user. Null value of query object will return all records of User in given collection."

So as the explanation, I shoud be received the records in leaderboard that only belong to individual user (John for example)
I am stuck in this problem. Can you check if it's a bug with the AS3 SDK?
Hi Sharma, are you still watching this topic?
This is working as per the expected behaviour and it is not a bug. Setting collection and query will fetch additional records of user data who are present in the leaderboard. If you will not set collection name and query, it will return leaderboard with username and respective score only.

Lets say there are top 3 rankers in leaderboard John, Foo and Bar. Calling  getTopNRankers(N=3) without passing collectionname and query will return just name (John, Foo, Bar) and their respective scores and rank. Now if you have saved additional information of these users in collection (say profile). You can set collection name (profile) and query while fetching the leaderboard using getTopNRankers (N=3), and this time you will get JSON document of each user (John, Foo,Bar) in the leaderboard along with Score.

Let me know if this is helpful.
Hi Ajay123,

I see that your explanation is exactly what I understand, too.
So we are misunderstanding eachother.

To make problem more simple, can you take a look at my code above (at step 2), and show me where still not correct?

It's best if you can suggest me a way to do it (by AS3 code).

My aim is to fetch only the records in leaderboard belongs to user "John".

Thanks in advandce.
You can use QueryBuilder.setLoggedInUser("John") and pass this in SetQuery method before making call to leaderboard. This will return 3 users in leaderbaord (John, Foo, Bar) however this will only have additional JSON records of user John. Foo and Bar user will not have any additional JSON records in the leaderboard however they will be in leaderboard ranking as before.
I hope your query has been resolved, let us know if you have more question for us.

Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com