Leaderboard additional data

0 votes

Hi, app42 support team:

 I call SaveUserScore to store scores and addtionnal data.

And I call GetTopNRankers to get  the  top 6 rank.

my code:

1. call 4 times: 
ScoreBoardResponse callBack = new ScoreBoardResponse ();
Dictionary<string, object> jsonDoc = new Dictionary<string, object> ();  
jsonDoc.Add("name","Stephen");  
jsonDoc.Add("LV", 2); // LV is different every time.(4, 5, 6)
App42API.SetDbName("Player1"); 
mScoreBoardService.AddJSONObject( "addtionnalData", jsonDoc); 
mScoreBoardService.SaveUserScore("LeaderBoardTest", "fearless", 179, callBack);
2. call 1 times:
String key1 = "name";     
String value1 = "Stephen";  
Query query = QueryBuilder.Build(key1, value1, Operator.EQUALS); 
App42API.SetDbName("Player1");  
mScoreBoardService.SetQuery("addtionnalData", query);     
mScoreBoardService.GetTopNRankers( "LeaderBoardTest", 6, callBack );   
 
Question:
I get 4 additionnal data for the user: "fearless"
53f0e34ee4b09d4fe2471842 : {"name":"Stephen", "LV":"2", "_$acl":[ {"PUBLIC":"R"} ]}
53f0e34ee4b09d4fe2451450 : {"name":"Stephen", "LV":"4", "_$acl":[ {"PUBLIC":"R"} ]}
53f0e34ee4b09d4fe2447847 : {"name":"Stephen", "LV":"5", "_$acl":[ {"PUBLIC":"R"} ]}
53f0e34ee4b09d4fe2429890 : {"name":"Stephen", "LV":"6", "_$acl":[ {"PUBLIC":"R"} ]}
eg:
user                            score                           LV(additional data)
fearless                      179                              2
fearless                      181                              4
fearless                      182                              5
fearless                      183                              6
adf                                153                              1
but I call GetTopNRankers, I get:
fearless      183      2, 4, 5, 6    // Question1: there: i dinn't know which LV I should use?????
adf                153     1
 
I only want to get  "fearless                      183                              the latest LV".
Please help me, thanks!
Question 2: Is there a way to store one addtional data for one user???
 
 
asked Aug 18, 2014 in App42 Cloud API-BaaS by riovoxtools (45 points)
edited Aug 18, 2014 by riovoxtools

1 Answer

0 votes
 
Best answer

You can add score value in JSON object to identify corresponding score for it. For example you can add score something like this

jsonDoc.Add("Score", 179); 
 
while saving the score. After fetching the score you can easily link which JSON object to use  for corresponding score.
We have logged this issue in your release and will add the provision to link JSON object for corresponding score using score Id.
 
Thanks
Ajay
answered Aug 18, 2014 by ajay123 (899 points)
selected Aug 19, 2014 by riovoxtools
Hi, Ajay,
Thank you for your reply, it's a good idea for identifing corresponding score.
user                            score                           LV(additional data)
fearless                      179                              2
fearless                      181                              4
fearless                      182                              5
fearless                      183                              6
fearless                      178                              7
fearless                       176                             8
But I want to the the top score: 183, and get the latest LV:8(is not 6)
How to solve this problem??
There is a createdAt field in JSON object, this will give you the info about latest doc of this user.
Thank you, ajay,
Can I share one additional data for one user when i call SaveUserScore?
I don't need to save more than one additional data for one user.
If you want to just have one data for user, dont save it in every save score call, instead call it once using Storage service directly and fetch this data back in leaderboard. This is explained here in our blog posting

http://blogs.shephertz.com/2014/04/08/saving-additional-data-fetching-back-app42-leaderboard/

Let me know if it helps.
Thank you , it works!
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
...