Sign In Register

How can we help you today?

Start a new topic
Answered

When is GS_DAILY Called & Why isn't it executing my module?

Is the "Every Day" system script called at the beginning of a new day or at the end of the day?

I'm trying to reward the top X players in my leaderboard from the previous day. Within the GS_DAILY script I have this: 

 

require("dailyArenaReward");


The dailyArenaReward module looks like this:


var dd = new Date();


//Get Yesterday's date

dd.setDate(dd.getDate()-1);


//Create the shortcode for the daily leaderboard partition

var YYYY = dd.getFullYear();

var MM = dd.getMonth()+1;

if(MM < 10)

    MM = '0'+MM;

var DD = dd.getDate();

if(DD < 10)

    DD = '0'+DD;

var dayString = YYYY+''+MM+''+DD; 

var shortcode = "dailyArena.day."+dayString;


//Get the Leaderboard entries with our shortcode

var request = new SparkRequests.LeaderboardDataRequest();

request.leaderboardShortCode = shortcode;

request.entryCount = 5001; 

var response = request.Send();

var topN = []; 


for(entry in response.data)

{

    topN.push(response.data[entry].userId);

}


//Loop through the top 5000 players, setting their rank in their private data which will be checked upon login.

for(i = 0; i < topN.length; i ++)

{

    var player = Spark.loadPlayer(topN[i]);

    player.setPrivateData("dailyRank", (i+1));

}



But this module isn't being run for some reason, because when I log in after 00:00 UTC for a new day, the player still has a null value for their private data "dailyRank" which SHOULD be set from the Every Day script. But If I put require("dailyArenaReward"); in the test harness, the module gets called and all players get their ranks set correctly.


So why is the module not being called in the every day script? And does GS_DAILY execute its code at the start or the end of the day?


Thanks for your time.

-Sean





screen.png
(3.06 MB)

Best Answer

Hi Sean,


The GS_DAILY System Script is executed at 00:00UTC daily.


To investigate this further I would do 2 things.


1) - Put some logging in your GS_DAILY script at regular intervals to see what is happening and if anything is being called or executed. You can do this by using Spark.getLog().debug() and checking the script.log runtime collection.


2) - Try calling the module from an LogEvent for testing purposes and step through what is happening through the Test Harness debugger.


-Pádraig

1 Comment

Answer

Hi Sean,


The GS_DAILY System Script is executed at 00:00UTC daily.


To investigate this further I would do 2 things.


1) - Put some logging in your GS_DAILY script at regular intervals to see what is happening and if anything is being called or executed. You can do this by using Spark.getLog().debug() and checking the script.log runtime collection.


2) - Try calling the module from an LogEvent for testing purposes and step through what is happening through the Test Harness debugger.


-Pádraig

Login to post a comment