From 4a9dca9ffccb087135c6e2d0eebae45cd567036d Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Thu, 3 Nov 2022 17:45:27 +0200 Subject: Corrected typo, added 1h30min waiting time before the foods are updated You never know if the city's servers don't get updated instantly, so it might not be a good idea to ask for the foods at (at worst) 1 ms after 00:00 at monday. --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server.js') 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 -- cgit v1.2.3 From 0f2d56eafd01b5e728f96cf327f1a3e881a21225 Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 5 Nov 2022 13:07:11 +0200 Subject: Hid vegetarian food when it is the same as the normal food. Added date logging to init.sh. --- server.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server.js') diff --git a/server.js b/server.js index 905fe63..c2b0449 100644 --- a/server.js +++ b/server.js @@ -283,7 +283,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 From d10272298acb4d6e07fb5b73dd7af06d653afd7b Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Fri, 18 Nov 2022 18:27:40 +0200 Subject: Updated exam/vacation/etc notifications. Now they don't block the search field, which is more user friendly. They also appear only if the date searched for matches the notification, not if the current date matches the notification. --- server.js | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'server.js') diff --git a/server.js b/server.js index c2b0449..ccab1b7 100644 --- a/server.js +++ b/server.js @@ -182,7 +182,7 @@ async function buildMain(args) let day = d.getDay(); day = (day + +(day === 0) * 7) - 1; // converts from 0 = sunday to 0 = monday const actualDay = day; - day = +(!(day === 5) && !(day === 6)) * day; + day = +(!(day === 5) && !(day === 6)) * day; // resets day to monday if saturday or sunday if ((typeof query.day === "string") && (parseInt(query.day).toString() === query.day) && (!isNaN(parseInt(query.day))) && (parseInt(query.day) >= 0) && (parseInt(query.day) < 5)) day = parseInt(query.day); // set the day selected (must be done manually with this replacement system) @@ -239,16 +239,21 @@ async function buildMain(args) const examInfo = await SQLDB.query("SELECT * FROM exams"); for(let week = 0; week < examInfo.length; week++) { + // get the date of the requested day + 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); } } -- cgit v1.2.3