Route Update All Monitor/Team Checks

This commit is contained in:
Br0wnHammer
2025-06-20 16:11:22 +05:30
parent e8908351a2
commit a9c1d131a5
4 changed files with 68 additions and 0 deletions
+24
View File
@@ -261,6 +261,29 @@ const updateCheckStatus = async (checkId, status) => {
}
};
/**
* Update the status of all checks for a monitor or team
* @async
* @param {string} id
* @param {boolean} status
* @param {string} target
* @returns {Promise<number>}
* @throws {Error}
*/
const updateAllChecksStatus = async (id, status, target) => {
try {
const updatedChecks = await Check.updateMany(
target === "monitor" ? { monitorId: id } : { teamId: id },
{ $set: { status: true } }
);
return updatedChecks.modifiedCount;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "updateAllChecksStatus";
throw error;
}
};
/**
* Delete all checks for a monitor
* @async
@@ -343,6 +366,7 @@ export {
getChecksByMonitor,
getChecksByTeam,
updateCheckStatus,
updateAllChecksStatus,
deleteChecks,
deleteChecksByTeamId,
updateChecksTTL,