Implemented pagination for incidents component
This commit is contained in:
1 parent
3924099e3e
commit
26e3f81a91
7 files changed
+131
-176
No files matched your search
+13
-12
@@ -4,7 +4,7 @@ const Notification = require("../models/Notification");
|
||||
|
||||
/**
|
||||
* Check Schema for MongoDB collection.
|
||||
*
|
||||
*
|
||||
* Represents a check associated with a monitor, storing information
|
||||
* about the status and response of a particular check event.
|
||||
*/
|
||||
@@ -12,7 +12,7 @@ const CheckSchema = mongoose.Schema(
|
||||
{
|
||||
/**
|
||||
* Reference to the associated Monitor document.
|
||||
*
|
||||
*
|
||||
* @type {mongoose.Schema.Types.ObjectId}
|
||||
*/
|
||||
monitorId: {
|
||||
@@ -22,7 +22,7 @@ const CheckSchema = mongoose.Schema(
|
||||
},
|
||||
/**
|
||||
* Status of the check (true for up, false for down).
|
||||
*
|
||||
*
|
||||
* @type {Boolean}
|
||||
*/
|
||||
status: {
|
||||
@@ -30,23 +30,23 @@ const CheckSchema = mongoose.Schema(
|
||||
},
|
||||
/**
|
||||
* Response time of the check in milliseconds.
|
||||
*
|
||||
*
|
||||
* @type {Number}
|
||||
*/
|
||||
responseTime: {
|
||||
type: Number,
|
||||
type: Number,
|
||||
},
|
||||
/**
|
||||
* HTTP status code received during the check.
|
||||
*
|
||||
*
|
||||
* @type {Number}
|
||||
*/
|
||||
statusCode: {
|
||||
type: Number,
|
||||
type: Number,
|
||||
},
|
||||
/**
|
||||
* Message or description of the check result.
|
||||
*
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
message: {
|
||||
@@ -54,7 +54,7 @@ const CheckSchema = mongoose.Schema(
|
||||
},
|
||||
/**
|
||||
* Expiry date of the check, auto-calculated to expire after 30 days.
|
||||
*
|
||||
*
|
||||
* @type {Date}
|
||||
*/
|
||||
expiry: {
|
||||
@@ -70,7 +70,7 @@ const CheckSchema = mongoose.Schema(
|
||||
|
||||
/**
|
||||
* Pre-save middleware to handle status change notifications.
|
||||
*
|
||||
*
|
||||
* This middleware checks if the status of the monitor associated
|
||||
* with the check has changed and sends notifications if necessary.
|
||||
*/
|
||||
@@ -79,7 +79,9 @@ CheckSchema.pre("save", async function (next) {
|
||||
const monitor = await mongoose.model("Monitor").findById(this.monitorId);
|
||||
|
||||
if (monitor) {
|
||||
const notifications = await Notification.find({ monitorId: this.monitorId });
|
||||
const notifications = await Notification.find({
|
||||
monitorId: this.monitorId,
|
||||
});
|
||||
|
||||
// Check if there are any notifications
|
||||
if (notifications && notifications.length > 0) {
|
||||
@@ -128,5 +130,4 @@ CheckSchema.pre("save", async function (next) {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module.exports = mongoose.model("Check", CheckSchema);
|
||||
Reference in new issue
Block a user