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:
Alexander Holliday authored and GitHub committed 2025-07-28 11:40:30 -07:00
commit 051c17f454
1 file changed
+52 -1
@@ -135,6 +135,14 @@ const getStatusPage = async (url) => {
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "maintenancewindows",
let: { monitorId: "$monitors._id" },
pipeline: [{ $match: { $expr: { $eq: ["$monitorId", "$$monitorId"] } } }],
as: "monitors.maintenanceWindows",
},
},
{
$lookup: {
from: "checks",
@@ -156,6 +164,20 @@ const getStatusPage = async (url) => {
"monitors.orderIndex": {
$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 } } },
@@ -183,7 +205,36 @@ const getStatusPage = async (url) => {
showAdminLoginLink: 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,
},
},
},
]);