Sign In Register

How can we help you today?

Start a new topic
Answered

Configure Weekly Reset Leaderboard to start on Mondays

Hi!


Can we somehow configure our Weekly Reset Leaderboard to start a week on mondays?

And second question - we need to trigger external API call on leaderboard reset with collected resulting data - can we do this in Cloud Code?


Thanks in advance!


Best Answer

I would create a module and function for that. Then automate it's execution (in this case sending off data to you api) based on the day you want(In this case monday). This module can be executed daily , with a check for the day you specify. 


For example: 

Go to Cloud code -> System-> every day. 


In here reference the module using : require("Module_Shortcode");

This module will have a function which sends off your data.The function will be executed in every day based on a check for the current day.  

That check can be done using the following bit of JavaScript: http://www.w3schools.com/jsref/jsref_getday.asp . 




Does this answer your question Aleksey? 


Regards, Patrick. 




Maybe someone have any suggestions? Really need help with this question.

Hi Aleksey,


You can indeed do that.


What you need to do is create an event for posting your weekly score. Then set that events attributes as the running totals for a new Weekly Leaderboard.  

Here is a basic Template: 


*Note,the default value for week is an in built function. It sets the time stamp as being the most recent Monday i.e today. It will then check that time stamp and only upload a new score if the current week has changed. The week changes at 00:00 AM every Monday.  


This event will be the running total for your new weekly leader board. Best practice is to call it in conjunction with your realtime score event as we won't update the board anyway without the startOfWeek() function returning a new Monday. 


Here is the weekly LeaderBoard Configuration.




Should you need additional help, don't hesitate to contact us. 


Regards , Patrick. 


Thanks, that works!

Can you maybe suggest how we can send data to our API when week ends?

Answer

I would create a module and function for that. Then automate it's execution (in this case sending off data to you api) based on the day you want(In this case monday). This module can be executed daily , with a check for the day you specify. 


For example: 

Go to Cloud code -> System-> every day. 


In here reference the module using : require("Module_Shortcode");

This module will have a function which sends off your data.The function will be executed in every day based on a check for the current day.  

That check can be done using the following bit of JavaScript: http://www.w3schools.com/jsref/jsref_getday.asp . 




Does this answer your question Aleksey? 


Regards, Patrick. 



Thank you Patrick.


We've made almost the same manipulations but in Every Minute scheduler. We are checking if current time is 23:59 of Sunday and then send our data to our API.

Brilliant, That's even more precise than my method. Glad to have been of help. 

Any further questions , feel free to create a new topic. 

Regards, Patrick. 

Login to post a comment