mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-10-01 01:25:45 -04:00
Fix #2776
This commit is contained in:
parent
65933de0cd
commit
2dedc1cfbd
@ -41,6 +41,8 @@ class MaintenanceTimeslot extends BeanModel {
|
|||||||
* @returns {Promise<MaintenanceTimeslot>}
|
* @returns {Promise<MaintenanceTimeslot>}
|
||||||
*/
|
*/
|
||||||
static async generateTimeslot(maintenance, minDate = null, removeExist = false) {
|
static async generateTimeslot(maintenance, minDate = null, removeExist = false) {
|
||||||
|
log.info("maintenance", "Generate Timeslot for maintenance id: " + maintenance.id);
|
||||||
|
|
||||||
if (removeExist) {
|
if (removeExist) {
|
||||||
await R.exec("DELETE FROM maintenance_timeslot WHERE maintenance_id = ? ", [
|
await R.exec("DELETE FROM maintenance_timeslot WHERE maintenance_id = ? ", [
|
||||||
maintenance.id
|
maintenance.id
|
||||||
|
@ -272,6 +272,10 @@ class UptimeKumaServer {
|
|||||||
/** Load the timeslots for maintenance */
|
/** Load the timeslots for maintenance */
|
||||||
async generateMaintenanceTimeslots() {
|
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') ");
|
let list = await R.find("maintenance_timeslot", " generated_next = 0 AND start_date <= DATETIME('now') ");
|
||||||
|
|
||||||
for (let maintenanceTimeslot of list) {
|
for (let maintenanceTimeslot of list) {
|
||||||
|
Loading…
Reference in New Issue
Block a user