Merge pull request #2692 from bluewave-labs/feat/status-page-paintenance
feat: add isMaintenance field to monitors for status page queries
This commit is contained in:
1 file changed
+52
-1
@@ -135,6 +135,14 @@ const getStatusPage = async (url) => {
|
|||||||
preserveNullAndEmptyArrays: true,
|
preserveNullAndEmptyArrays: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
$lookup: {
|
||||||
|
from: "maintenancewindows",
|
||||||
|
let: { monitorId: "$monitors._id" },
|
||||||
|
pipeline: [{ $match: { $expr: { $eq: ["$monitorId", "$$monitorId"] } } }],
|
||||||
|
as: "monitors.maintenanceWindows",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: "checks",
|
from: "checks",
|
||||||
@@ -156,6 +164,20 @@ const getStatusPage = async (url) => {
|
|||||||
"monitors.orderIndex": {
|
"monitors.orderIndex": {
|
||||||
$indexOfArray: ["$originalMonitors", "$monitors._id"],
|
$indexOfArray: ["$originalMonitors", "$monitors._id"],
|
||||||
},
|
},
|
||||||
|
"monitors.isMaintenance": {
|
||||||
|
$reduce: {
|
||||||
|
input: "$monitors.maintenanceWindows",
|
||||||
|
initialValue: false,
|
||||||
|
in: {
|
||||||
|
$or: [
|
||||||
|
"$$value",
|
||||||
|
{
|
||||||
|
$and: [{ $eq: ["$$this.active", true] }, { $lte: ["$$this.start", "$$NOW"] }, { $gte: ["$$this.end", "$$NOW"] }],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ $match: { "monitors.orderIndex": { $ne: -1 } } },
|
{ $match: { "monitors.orderIndex": { $ne: -1 } } },
|
||||||
@@ -183,7 +205,36 @@ const getStatusPage = async (url) => {
|
|||||||
showAdminLoginLink: 1,
|
showAdminLoginLink: 1,
|
||||||
url: 1,
|
url: 1,
|
||||||
},
|
},
|
||||||
monitors: 1,
|
monitors: {
|
||||||
|
_id: 1,
|
||||||
|
userId: 1,
|
||||||
|
teamId: 1,
|
||||||
|
name: 1,
|
||||||
|
description: 1,
|
||||||
|
status: 1,
|
||||||
|
type: 1,
|
||||||
|
ignoreTlsErrors: 1,
|
||||||
|
jsonPath: 1,
|
||||||
|
expectedValue: 1,
|
||||||
|
matchMethod: 1,
|
||||||
|
url: 1,
|
||||||
|
port: 1,
|
||||||
|
isActive: 1,
|
||||||
|
interval: 1,
|
||||||
|
uptimePercentage: 1,
|
||||||
|
notifications: 1,
|
||||||
|
secret: 1,
|
||||||
|
thresholds: 1,
|
||||||
|
alertThreshold: 1,
|
||||||
|
cpuAlertThreshold: 1,
|
||||||
|
memoryAlertThreshold: 1,
|
||||||
|
diskAlertThreshold: 1,
|
||||||
|
tempAlertThreshold: 1,
|
||||||
|
checks: 1,
|
||||||
|
isMaintenance: 1,
|
||||||
|
createdAt: 1,
|
||||||
|
updatedAt: 1,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in new issue
Block a user