The start and end dates of the maintenance are now stored in UTC, which allows it to be converted between time zones

This commit is contained in:
Karel Krýda 2022-01-24 22:33:15 +01:00
parent 5fda1f0f59
commit e7b2832967
6 changed files with 33 additions and 34 deletions

View file

@ -51,7 +51,7 @@ router.get("/api/push/:pushToken", async (request, response) => {
duration = dayjs(bean.time).diff(dayjs(previousHeartbeat.time), "second");
}
const maintenance = await R.getAll("SELECT mm.*, maintenance.start_date, maintenance.end_date FROM monitor_maintenance mm JOIN maintenance ON mm.maintenance_id = maintenance.id WHERE mm.monitor_id = ? AND datetime(maintenance.start_date) <= datetime('now', 'localtime') AND datetime(maintenance.end_date) >= datetime('now', 'localtime')", [monitor.id]);
const maintenance = await R.getAll("SELECT mm.*, maintenance.start_date, maintenance.end_date FROM monitor_maintenance mm JOIN maintenance ON mm.maintenance_id = maintenance.id WHERE mm.monitor_id = ? AND datetime(maintenance.start_date) <= datetime('now') AND datetime(maintenance.end_date) >= datetime('now')", [monitor.id]);
if (maintenance.length !== 0) {
msg = "Monitor under maintenance";
status = MAINTENANCE;
@ -149,8 +149,8 @@ router.get("/api/status-page/maintenance-list", async (_request, response) => {
let maintenanceBeanList = R.convertToBeans("maintenance", await R.getAll(`
SELECT maintenance.*
FROM maintenance
WHERE datetime(maintenance.start_date) <= datetime('now', 'localtime')
AND datetime(maintenance.end_date) >= datetime('now', 'localtime')
WHERE datetime(maintenance.start_date) <= datetime('now')
AND datetime(maintenance.end_date) >= datetime('now')
ORDER BY maintenance.end_date
`));