When is GS_DAILY Called & Why isn't it executing my module?
S
Sean Young
started a topic
almost 6 years ago
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?
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
Customer Support
said
almost 6 years ago
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.
Sean Young
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
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
Customer Support
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
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics