pull/2906/head
Louis Lam 1 year ago
parent 65933de0cd
commit 2dedc1cfbd

@ -41,6 +41,8 @@ class MaintenanceTimeslot extends BeanModel {
* @returns {Promise<MaintenanceTimeslot>}
*/
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

@ -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) {

Loading…
Cancel
Save