Sign In Register

How can we help you today?

Start a new topic
Answered

LeaderboardDataRequest on an empty leaderboard returns INVALID error

Hi, just found out that, performing a LeaderbordDataRequest on an empty leaderboard will return an "INVALID" error. That's actually not an error, right? I'd suggest to return a response with its data empty, but not an error.


Thanks for looking into this,

Chris


Best Answer

Hi Chris,


I just realized I've been dealing with Javier from your team on a Ticket on the same issue. Basically whats happening here is this, as your Leaderboard is set to "Reset Weekly" the Leaderboard will never exist as "GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display", it will always have the ".SNAPSHOT" on the end, the date will be the beginning of the current week for a Reset Weekly Leaderboard. You will need to add this yourself on the client side when retrieving a leaderboard. You could also do a ListLeaderboardsRequest on the client side and get the shortCode from there. If you have any other questions just let me know.


Thanks,

Liam


Hi Christian,


Are you sure you are supplying a valid shortCode ? If I create a Leaderboard and perform a LeaderboardDataRequest on it with a valid shortCode I get the empty data response you are expecting.


{
 "@class": ".LeaderboardDataResponse",
 "data": [],
 "leaderboardShortCode": "testLB"
}


I also get the same result after I have cleared my Leaderboard and Running Total of all entries. If you can let me know the shortCode you are using and the name of your game I'll take a look into this for you.


Thanks,

Liam

Hi Liam,


Thanks for such a quick response. The current request I was sending is this one:


{

 "@class": ".LeaderboardDataRequest",

 "entryCount": 5,

 "leaderboardShortCode": "GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display"

}


And the response I'm getting is:


{
 "@class": ".LeaderboardDataResponse",
 "error": {
  "leaderboardShortCode": "INVALID"
 }
}



Thanks Liam,

Chris

Hi Chris,


Would you mind if I created a test user in your game to have a look at this a bit closer ?


Thanks,

Liam



Please go ahead.


Thanks,

Chris

Hi Chris,


I created a test user and had a look at your leaderboards, the "GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display" doesn't appear at all in a ListLeaderBoardsRequest, I'm not quite sure why. My empty Leaderboards show up fine, I'll investigate this some more and get back to you.


Thanks,

Liam

Hi Liam,


That's not quite possible, I just double checked and there are no typos in the name of the Leaderboard, I've got 26 on my game, I'd ask you if you are sure you are looking at the right game, but my account only holds 1 project right now, could you please make sure you are looking at the right place?


Thanks!

Hi again Liam,


Before continuing, let me add a little bit more information just in case. I've been checking the full configuration of the Leaderboard, and it looks like the problem is not entirely the fact that the LB is empty or not, but its configuration. The leaderboard's update schedule is "Reset Weekly", and it's being sorted by the Score read from an event which has 2 attributes: The Score, and a Day (which default value is ${today}, and its default Calc is Count). 


With this configuration testing via Test Harness this call:


{

 "@class": ".LeaderboardDataRequest",

 "entryCount": 1,

 "leaderboardShortCode": "GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display"

}


Returns this:


{
 "@class": ".LeaderboardDataResponse",
 "data": [
  {
   "userId": "573057c0f528a1ccf4a35025",
   "SCORE": 3275,
   "when": "2016-05-10T09:41Z",
   "city": "Barcelona",
   "country": "ES",
   "userName": "fs_68qawoe0b",
   "externalIds": {},
   "rank": 1
  }
 ],
 "leaderboardShortCode": "GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display.SNAPSHOT.2016-05-08"
}


Notice that there's a suffix added (.SNAPSHOT.2016-05-08)


So, now that there's data is being returned, and if I call the event that is linked to this leaderboard from the test harness (this line of code):

 

//Retrieve the leaderboards scores
        var weeklyMemberTotalLB = Spark.getLeaderboards().getLeaderboard("GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display").getEntriesFromPlayer(Spark.getPlayer().getPlayerId(), 1).next();


will return data, but if on the other hand, I call the event from my project, the variable 'weeklyMemberTotalLB' will be null instead. I just added some logs in order to test that and can confirm the issue.


Hope this extra info helps a little bit more.

Cheers,

Answer

Hi Chris,


I just realized I've been dealing with Javier from your team on a Ticket on the same issue. Basically whats happening here is this, as your Leaderboard is set to "Reset Weekly" the Leaderboard will never exist as "GUILD_WEEKLY_TOTAL_MEMBERS_LB_Display", it will always have the ".SNAPSHOT" on the end, the date will be the beginning of the current week for a Reset Weekly Leaderboard. You will need to add this yourself on the client side when retrieving a leaderboard. You could also do a ListLeaderboardsRequest on the client side and get the shortCode from there. If you have any other questions just let me know.


Thanks,

Liam

Hi Liam,


Sorry about that! Didn't realize we were asking about the same issue. 

All clear now, thanks!


Chris

Hi Chris,


No problem at all, I'll close Javiers ticket also if you guys have no further questions.


Thanks,

Liam

Login to post a comment