Route for Updating a single Incident Status

This commit is contained in:
Br0wnHammer committed 2025-06-20 15:39:13 +05:30
1 parent 205e16a96d
commit e8908351a2
6 files changed
+81 -5

No files matched your search

+28 -2
View File
@@ -68,7 +68,7 @@ const getChecksByMonitor = async ({
status,
}) => {
try {
status = typeof status !== "undefined" ? false : undefined;
status = status === "true" ? true : status === "false" ? false : undefined;
page = parseInt(page);
rowsPerPage = parseInt(rowsPerPage);
// Match
@@ -156,13 +156,15 @@ const getChecksByTeam = async ({
page,
rowsPerPage,
teamId,
status,
}) => {
try {
status = status === "true" ? true : false;
page = parseInt(page);
rowsPerPage = parseInt(rowsPerPage);
const matchStage = {
teamId: ObjectId.createFromHexString(teamId),
status: false,
status: status,
...(dateRangeLookup[dateRange] && {
createdAt: {
$gte: dateRangeLookup[dateRange],
@@ -236,6 +238,29 @@ const getChecksByTeam = async ({
}
};
/**
* Update the status of a check
* @async
* @param {string} checkId
* @param {boolean} status
* @returns {Promise<Check>}
* @throws {Error}
*/
const updateCheckStatus = async (checkId, status) => {
try {
const updatedCheck = await Check.findOneAndUpdate(
{ _id: checkId },
{ status },
{ new: true }
);
return updatedCheck;
} catch (error) {
error.service = SERVICE_NAME;
error.method = "updateCheckStatus";
throw error;
}
};
/**
* Delete all checks for a monitor
* @async
@@ -317,6 +342,7 @@ export {
createChecks,
getChecksByMonitor,
getChecksByTeam,
updateCheckStatus,
deleteChecks,
deleteChecksByTeamId,
updateChecksTTL,