diff --git a/data/.gitkeep b/data/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/server/model/maintenance_timeslot.js b/server/model/maintenance_timeslot.js index 77643c2cf..3e7076d8a 100644 --- a/server/model/maintenance_timeslot.js +++ b/server/model/maintenance_timeslot.js @@ -41,6 +41,8 @@ class MaintenanceTimeslot extends BeanModel { * @returns {Promise} */ static async generateTimeslot(maintenance, minDate = null, removeExist = false) { + log.info("maintenance", "Generate Timeslot for maintenance id: " + maintenance.id); + if (removeExist) { await R.exec("DELETE FROM maintenance_timeslot WHERE maintenance_id = ? ", [ maintenance.id diff --git a/server/uptime-kuma-server.js b/server/uptime-kuma-server.js index 0573f0d8c..a9c2289e7 100644 --- a/server/uptime-kuma-server.js +++ b/server/uptime-kuma-server.js @@ -272,6 +272,10 @@ class UptimeKumaServer { /** Load the timeslots for maintenance */ async generateMaintenanceTimeslots() { + // Prevent #2776 + // Remove duplicate maintenance_timeslot with same start_date, end_date and maintenance_id + await R.exec("DELETE FROM maintenance_timeslot WHERE id NOT IN (SELECT MIN(id) FROM maintenance_timeslot GROUP BY start_date, end_date, maintenance_id)"); + let list = await R.find("maintenance_timeslot", " generated_next = 0 AND start_date <= DATETIME('now') "); for (let maintenanceTimeslot of list) {