From 9760c6242572f6ed17890b84ec3d14fa414b7579 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Wed, 21 Jun 2023 12:30:58 +0300 Subject: Some patches made in production :facepalm: At least some of them have to do with running updations timely? --- server.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index c496b14..04192a3 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 @@ -239,16 +239,19 @@ async function buildMain(args) const examInfo = await SQLDB.query("SELECT * FROM exams"); for(let week = 0; week < examInfo.length; week++) { + const nextDate = new Date( + d.getFullYear(), + d.getMonth(), + d.getDate() + day - actualDay + (day < actualDay)*7 + ); if (dateFuncs.between( - d, + nextDate, new Date(examInfo[week].start), new Date(examInfo[week].end) )) { - const message = "
" + - `
${examInfo[week].message}
` + - "${examInfo[week].message}
`; + data_string = strFuncs.replaceElement(data_string, "div id=\"shift-result\" class=\"float-block\"", message); } } @@ -283,7 +286,7 @@ async function buildMain(args) res["food-header"] = `Kouluruoka ${weekdays[day]}`; res["food"] = "Päivän ruoka puuttuu tietokannasta."; } - if (vege[0] !== undefined) { + if ((vege[0] !== undefined) && (vege[0].food !== res["food"])) { res["vege-header"] = vege[0].header; res["vege"] = vege[0].food; } else { -- cgit v1.2.3