Sign In Register

How can we help you today?

Start a new topic
Answered

Leaderboard - daily reset of SUM

Hi,


I am trying to create a leaderboard which sums up players' score - that is player can post score multiple times and it is added together. So I created an event to post a score, set its 'score' attribute Default Calc to Sum, then used this event in the Leaderboard setup and set the 'score' attribute Group to SUM. This works as expected. The problem occurs when the leaderboard is reset next day. The data is erased (correct) but when player posts a score on this new day the score continues to add up where it ended on the previous day. I would rather it simply starts adding up from zero every day.


Is it possible to achieve this setup in the GUI portal, or perhaps some custom CloudCode?


Thanks in advance.


Marcel


Best Answer

Hi Marcel,


When your Leaderboard resets daily, the running total data is preserved as a precaution as its possible that it's being used in another Leaderboard. This is why when you post a score the next day, it's added to the previous days total.


To clear a leaderboard and running total in cloud code you would use the following.


var leaderboard = Spark.getLeaderboards().getLeaderboard("myLeaderboard");

leaderboard.drop(true);


You could also partition your Leaderboards by day, which when set up correctly will group the days scores and running total info into a separate partition, giving each day a fresh Leaderboard to start with. If you need any more help with this just let me know.


Thanks,

Liam


Answer

Hi Marcel,


When your Leaderboard resets daily, the running total data is preserved as a precaution as its possible that it's being used in another Leaderboard. This is why when you post a score the next day, it's added to the previous days total.


To clear a leaderboard and running total in cloud code you would use the following.


var leaderboard = Spark.getLeaderboards().getLeaderboard("myLeaderboard");

leaderboard.drop(true);


You could also partition your Leaderboards by day, which when set up correctly will group the days scores and running total info into a separate partition, giving each day a fresh Leaderboard to start with. If you need any more help with this just let me know.


Thanks,

Liam

Hi Liam,


Thanks for the 'group by day' tip, I will definitely try that.


Also, is it possible to somehow force the leaderboard to reset to make the daily snapshot? Waiting entire day to see if my changes are correct seems very unproductive.


Thanks again,


Marcel

Hi Marcel,


No problem, sadly there isn't a way to force it to see the changes early although if it is set up correct once you post a score it will be moved into todays partition, let me know how you get on with this and if it works ok for you. As always, if you have any follow up questions just let me know.


Thanks,

Liam

I need more or less the same thing, but I'm afraid I need it with months instead of days. Now I've seen in the tutorials that I can "group" events by DAY, providing an expression as default parameter (https://docs.gamesparks.net/howtos/leaderboards-howtos/how-to-create-time-based-leaderboards), but the expressions listed there don't really allow me to do anything with months.


So, how would I create a leaderboard that ranks users on the total score (summed over all 'scoring' events) they've achieved this calendar month? Is there, by now, an expression that allows me to have the current month as default parameter? Or should I just add this in Cloud Code? [

Hi Rene,


The default parameter you're looking for is:
 ${today:startOfMonth()}


Let me know if that helps.

Thanks,


Oisin.

Hi Oisin,


It might help, thanks. For now, due to a requirements change, I'll be implementing a different leaderboard, but this might still help someone down the road.


Are these parameters documented somewhere where I couldn't find them? If not, perhaps you could document it somewhere (and add the link to the time-based leaderboard tutorial?)


Regards and thanks,

René

Thanks Rene,

We're overhauling all our docs and tutorials in the coming months and will include those parameters soon.

Thanks,


Oisin

Hi,

I would like to know more about The default parameters.


I need to build a leaderboard weekly which reset every week, and updates should be still real-time.


Ex: 

Monday - Sunday. 

On the beginning of Mon. The leaderboard has nothing.

On Sat. I can see the sum Of events from Monday to Sat.


Thanks

Login to post a comment