parse form for submission
This commit is contained in:
1 parent
5f96b17595
commit
c8418705b1
3 files changed
+43
-15
No files matched your search
@@ -6,7 +6,7 @@ const mongoose = require("mongoose");
|
||||
* @typedef {Object} MaintenanceWindow
|
||||
* @property {mongoose.Schema.Types.ObjectId} monitorId - The ID of the monitor. This is a reference to the Monitor model and is immutable.
|
||||
* @property {Boolean} active - Indicates whether the maintenance window is active.
|
||||
* @property {Boolean} oneTime - Indicates whether the maintenance window is a one-time event.
|
||||
* @property {Number} repeat - Indicates how often this maintenance window should repeat.
|
||||
* @property {Date} start - The start date and time of the maintenance window.
|
||||
* @property {Date} end - The end date and time of the maintenance window.
|
||||
* @property {Date} expiry - The expiry date and time of the maintenance window. This is used for MongoDB's TTL index to automatically delete the document at this time. This field is set to the same value as `end` when `oneTime` is `true`.
|
||||
@@ -16,12 +16,12 @@ const mongoose = require("mongoose");
|
||||
* let maintenanceWindow = new MaintenanceWindow({
|
||||
* monitorId: monitorId,
|
||||
* active: active,
|
||||
* oneTime: oneTime,
|
||||
* repeat: repeat,
|
||||
* start: start,
|
||||
* end: end,
|
||||
* });
|
||||
*
|
||||
* if (oneTime) {
|
||||
* if (repeat === 0) {
|
||||
* maintenanceWindow.expiry = end;
|
||||
* }
|
||||
*
|
||||
@@ -41,9 +41,10 @@ const MaintenanceWindow = mongoose.Schema(
|
||||
},
|
||||
active: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
oneTime: {
|
||||
type: Boolean,
|
||||
repeat: {
|
||||
type: Number,
|
||||
},
|
||||
start: {
|
||||
type: Date,
|
||||
|
||||
@@ -84,7 +84,15 @@ class JobQueue {
|
||||
if (window.active) {
|
||||
const start = new Date(window.start);
|
||||
const end = new Date(window.end);
|
||||
if (start < new Date() && end > new Date()) {
|
||||
const now = new Date();
|
||||
const repeatInterval = window.repeat || 0;
|
||||
|
||||
while (start < now) {
|
||||
start.setDate(start.getTime() + repeatInterval);
|
||||
end.setDate(end.getTime() + repeatInterval);
|
||||
}
|
||||
|
||||
if (start < now && end > now) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -139,9 +147,7 @@ class JobQueue {
|
||||
return { jobs, load };
|
||||
} catch (error) {
|
||||
error.service === undefined ? (error.service = SERVICE_NAME) : null;
|
||||
error.method === undefined
|
||||
? (error.method = "getWorkerStats")
|
||||
: null;
|
||||
error.method === undefined ? (error.method = "getWorkerStats") : null;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user