fix DU operations

This commit is contained in:
Alex Holliday committed 2025-02-05 13:59:28 -08:00
1 parent b9bcc893b0
commit 85a5b83ab8
5 files changed
+51 -1

No files matched your search

@@ -138,6 +138,7 @@ class DistributedUptimeController {
clearInterval(keepAlive); clearInterval(keepAlive);
}); });
} catch (error) { } catch (error) {
console.log(error);
next(handleError(error, SERVICE_NAME, "getDistributedUptimeMonitors")); next(handleError(error, SERVICE_NAME, "getDistributedUptimeMonitors"));
} }
} }
+6
View File
@@ -43,6 +43,11 @@ import * as hardwareCheckModule from "./modules/hardwareCheckModule.js";
import * as checkModule from "./modules/checkModule.js"; import * as checkModule from "./modules/checkModule.js";
//****************************************
// Distributed Checks
//****************************************
import * as distributedCheckModule from "./modules/distributedCheckModule.js";
//**************************************** //****************************************
// Maintenance Window // Maintenance Window
//**************************************** //****************************************
@@ -74,6 +79,7 @@ class MongoDB {
Object.assign(this, pageSpeedCheckModule); Object.assign(this, pageSpeedCheckModule);
Object.assign(this, hardwareCheckModule); Object.assign(this, hardwareCheckModule);
Object.assign(this, checkModule); Object.assign(this, checkModule);
Object.assign(this, distributedCheckModule);
Object.assign(this, maintenanceWindowModule); Object.assign(this, maintenanceWindowModule);
Object.assign(this, notificationModule); Object.assign(this, notificationModule);
Object.assign(this, settingsModule); Object.assign(this, settingsModule);
@@ -0,0 +1,15 @@
import DistributedUptimeCheck from "../../models/DistributedUptimeCheck.js";
const SERVICE_NAME = "distributedCheckModule";
const createDistributedCheck = async (checkData) => {
try {
const check = await new DistributedUptimeCheck({ ...checkData }).save();
return check;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "createCheck";
throw error;
}
};
export { createDistributedCheck };
+24
View File
@@ -674,6 +674,26 @@ const getMonitorsByTeamId = async (req) => {
}, },
] ]
: []), : []),
...(limit
? [
{
$lookup: {
from: "distributeduptimechecks",
let: { monitorId: "$_id" },
pipeline: [
{
$match: {
$expr: { $eq: ["$monitorId", "$$monitorId"] },
},
},
{ $sort: { createdAt: -1 } },
...(limit ? [{ $limit: limit }] : []),
],
as: "distributeduptimechecks",
},
},
]
: []),
{ {
$addFields: { $addFields: {
@@ -692,6 +712,10 @@ const getMonitorsByTeamId = async (req) => {
case: { $eq: ["$type", "hardware"] }, case: { $eq: ["$type", "hardware"] },
then: "$hardwarechecks", then: "$hardwarechecks",
}, },
{
case: { $eq: ["$type", "distributed_http"] },
then: "$distributeduptimechecks",
},
], ],
default: [], default: [],
}, },
+5 -1
View File
@@ -244,7 +244,11 @@ const startApp = async () => {
ServiceRegistry.get(MongoDB.SERVICE_NAME) ServiceRegistry.get(MongoDB.SERVICE_NAME)
); );
const distributedUptimeController = new DistributedUptimeController(); const distributedUptimeController = new DistributedUptimeController(
ServiceRegistry.get(MongoDB.SERVICE_NAME),
http,
ServiceRegistry.get(StatusService.SERVICE_NAME)
);
//Create routes //Create routes
const authRoutes = new AuthRoutes(authController); const authRoutes = new AuthRoutes(authController);