Ack Field in Checks

This commit is contained in:
Br0wnHammer committed 2025-06-23 22:07:03 +05:30
1 parent faa2a2d965
commit 30d85e5712
6 files changed
+42 -26

No files matched your search

@@ -32,13 +32,11 @@ const IncidentTable = ({
const selectedMonitorDetails = monitors?.[selectedMonitor];
const selectedMonitorType = selectedMonitorDetails?.type;
const status = filter === "resolved" ? true : false;
const [checksMonitor, checksCountMonitor, isLoadingMonitor, networkErrorMonitor] =
useFetchChecksByMonitor({
monitorId: selectedMonitor === "0" ? undefined : selectedMonitor,
type: selectedMonitorType,
status: status,
status: false,
sortOrder: "desc",
limit: null,
dateRange,
@@ -50,7 +48,7 @@ const IncidentTable = ({
const [checksTeam, checksCountTeam, isLoadingTeam, networkErrorTeam] =
useFetchChecksTeam({
status: status,
status: false,
sortOrder: "desc",
limit: null,
dateRange,
+1 -1
View File
@@ -612,7 +612,7 @@ class NetworkService {
*/
async updateCheckStatus(config) {
return this.axiosInstance.put(`/checks/${config.checkId}`, {
status: config.status,
ack: config.ack,
});
}
+4 -8
View File
@@ -119,9 +119,9 @@ class CheckController {
try {
const { checkId } = req.params;
const { status } = req.body;
const { ack } = req.body;
const updatedCheck = await this.db.updateCheckStatus(checkId, status);
const updatedCheck = await this.db.updateCheckStatus(checkId, ack);
return res.success({
msg: this.stringService.checkUpdateStatus,
@@ -143,13 +143,9 @@ class CheckController {
try {
const { monitorId, target } = req.params;
const { status } = req.body;
const { ack } = req.body;
const updatedChecks = await this.db.updateAllChecksStatus(
monitorId,
status,
target
);
const updatedChecks = await this.db.updateAllChecksStatus(monitorId, ack, target);
return res.success({
msg: this.stringService.checkUpdateStatus,
+17
View File
@@ -64,6 +64,23 @@ const BaseCheckSchema = mongoose.Schema({
default: Date.now,
expires: 60 * 60 * 24 * 30, // 30 days
},
/**
* Acknowledgment of the check.
*
* @type {Boolean}
*/
ack: {
type: Boolean,
default: false,
},
/**
* Resolution date of the check (when the check was resolved).
*
* @type {Date}
*/
ackAt: {
type: Date,
},
});
/**
+16 -11
View File
@@ -239,20 +239,25 @@ const getChecksByTeam = async ({
};
/**
* Update the status of a check
* Update the acknowledgment status of a check
* @async
* @param {string} checkId
* @param {boolean} status
* @param {string} checkId - The ID of the check to update
* @param {boolean} ack - The acknowledgment status to set
* @returns {Promise<Check>}
* @throws {Error}
*/
const updateCheckStatus = async (checkId, status) => {
const updateCheckStatus = async (checkId, ack) => {
try {
const updatedCheck = await Check.findOneAndUpdate(
{ _id: checkId },
{ status },
{ $set: { ack, ackAt: new Date() } },
{ new: true }
);
if (!updatedCheck) {
throw new Error("Check not found");
}
return updatedCheck;
} catch (error) {
error.service = SERVICE_NAME;
@@ -262,19 +267,19 @@ const updateCheckStatus = async (checkId, status) => {
};
/**
* Update the status of all checks for a monitor or team
* Update the acknowledgment status of all checks for a monitor or team
* @async
* @param {string} id
* @param {boolean} status
* @param {string} target
* @param {string} id - The monitor ID or team ID
* @param {boolean} ack - The acknowledgment status to set
* @param {string} target - The target type ('monitor' or 'team')
* @returns {Promise<number>}
* @throws {Error}
*/
const updateAllChecksStatus = async (id, status, target) => {
const updateAllChecksStatus = async (id, ack, target) => {
try {
const updatedChecks = await Check.updateMany(
target === "monitor" ? { monitorId: id } : { teamId: id },
{ $set: { status } }
{ $set: { ack, ackAt: new Date() } }
);
return updatedChecks.modifiedCount;
} catch (error) {
+2 -2
View File
@@ -290,7 +290,7 @@ const createCheckBodyValidation = joi.object({
});
const updateCheckStatusBodyValidation = joi.object({
status: joi.boolean(),
ack: joi.boolean(),
});
const updateCheckStatusParamValidation = joi.object({
@@ -299,7 +299,7 @@ const updateCheckStatusParamValidation = joi.object({
});
const updateAllChecksStatusBodyValidation = joi.object({
status: joi.boolean(),
ack: joi.boolean(),
});
const getChecksParamValidation = joi.object({