aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Functions/dateFuncs.js7
-rw-r--r--server.js2
2 files changed, 5 insertions, 4 deletions
diff --git a/Functions/dateFuncs.js b/Functions/dateFuncs.js
index 55a9372..340b46e 100644
--- a/Functions/dateFuncs.js
+++ b/Functions/dateFuncs.js
@@ -46,9 +46,10 @@ function run_at_monday_mornings(func) {
days_to_elapse = 8 - weekday;
ms_to_elapse = ms_in_h * (
days_to_elapse * 24/*hours in a day*/
- - hour // removes unneccessary hours so that we update it at 0 am
- ) + 1 /*+1 so that we know that it won't be exactly midnight
- and possibly sunday. idk if this actually is needed.*/;
+ - hour + 1.5 // removes unneccessary hours so that we update it at 1:30 am
+ // 1:30 just in case the foods aren't updated instantly to the city's
+ // servers.
+ );
setTimeout(() => run_at_monday_mornings(func), ms_to_elapse);
diff --git a/server.js b/server.js
index c496b14..905fe63 100644
--- a/server.js
+++ b/server.js
@@ -50,7 +50,7 @@ async function init()
// ...shifts and classes
await updateDB.update(SQLDB, "../Updation/shifts.txt", "../Updation/vanhalops.csv", "../Updation/uusilops.csv");
// ...foods
- run_at_monday_mornings(() => food.build(SQLDB));
+ dateFuncs.run_at_monday_mornings(() => food.build(SQLDB));
if ((new Date()).getDay() !== 1) // update if it's not monday. if it's monday, it has already been run by the scheduler above.
await food.build(SQLDB);
// server code