mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-03 15:09:34 -05:00
Route Update All Monitor/Team Checks
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user