mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-21 09:09:43 -06:00
Naming Changes in BE
This commit is contained in:
@@ -8,6 +8,7 @@ const useFetchChecksTeam = ({
|
||||
limit,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
enabled = true,
|
||||
@@ -29,6 +30,7 @@ const useFetchChecksTeam = ({
|
||||
limit,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
};
|
||||
@@ -47,7 +49,7 @@ const useFetchChecksTeam = ({
|
||||
};
|
||||
|
||||
fetchChecks();
|
||||
}, [status, sortOrder, limit, dateRange, filter, page, rowsPerPage, enabled]);
|
||||
}, [status, sortOrder, limit, dateRange, filter, ack, page, rowsPerPage, enabled]);
|
||||
|
||||
return [checks, checksCount, isLoading, networkError];
|
||||
};
|
||||
@@ -60,6 +62,7 @@ const useFetchChecksByMonitor = ({
|
||||
limit,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
enabled = true,
|
||||
@@ -83,6 +86,7 @@ const useFetchChecksByMonitor = ({
|
||||
limit,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
};
|
||||
@@ -109,6 +113,7 @@ const useFetchChecksByMonitor = ({
|
||||
limit,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
enabled,
|
||||
|
||||
@@ -41,6 +41,7 @@ const IncidentTable = ({
|
||||
limit: null,
|
||||
dateRange,
|
||||
filter: filter === "resolved" ? "all" : filter,
|
||||
ack: filter === "resolved" ? true : false,
|
||||
page: page,
|
||||
rowsPerPage: rowsPerPage,
|
||||
enabled: selectedMonitor !== "0",
|
||||
@@ -53,6 +54,7 @@ const IncidentTable = ({
|
||||
limit: null,
|
||||
dateRange,
|
||||
filter: filter === "resolved" ? "all" : filter,
|
||||
ack: filter === "resolved" ? true : false,
|
||||
page: page,
|
||||
rowsPerPage: rowsPerPage,
|
||||
enabled: selectedMonitor === "0",
|
||||
|
||||
@@ -549,6 +549,7 @@ class NetworkService {
|
||||
* @param {number} config.limit - The maximum number of checks to retrieve.
|
||||
* @param {string} config.dateRange - The range of dates for which to retrieve checks.
|
||||
* @param {string} config.filter - The filter to apply to the checks.
|
||||
* @param {boolean} config.ack - The acknowledgment status to apply to the checks.
|
||||
* @param {number} config.page - The page number to retrieve in a paginated list.
|
||||
* @param {number} config.rowsPerPage - The number of rows per page in a paginated list.
|
||||
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
||||
@@ -562,6 +563,7 @@ class NetworkService {
|
||||
if (config.limit) params.append("limit", config.limit);
|
||||
if (config.dateRange) params.append("dateRange", config.dateRange);
|
||||
if (config.filter) params.append("filter", config.filter);
|
||||
if (config.ack !== undefined) params.append("ack", config.ack);
|
||||
if (config.page) params.append("page", config.page);
|
||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||
if (config.status !== undefined) params.append("status", config.status);
|
||||
@@ -581,6 +583,7 @@ class NetworkService {
|
||||
* @param {number} config.limit - The maximum number of checks to retrieve.
|
||||
* @param {string} config.dateRange - The range of dates for which to retrieve checks.
|
||||
* @param {string} config.filter - The filter to apply to the checks.
|
||||
* @param {boolean} config.ack - The acknowledgment status to apply to the checks.
|
||||
* @param {number} config.page - The page number to retrieve in a paginated list.
|
||||
* @param {number} config.rowsPerPage - The number of rows per page in a paginated list.
|
||||
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
||||
@@ -592,6 +595,7 @@ class NetworkService {
|
||||
if (config.limit) params.append("limit", config.limit);
|
||||
if (config.dateRange) params.append("dateRange", config.dateRange);
|
||||
if (config.filter) params.append("filter", config.filter);
|
||||
if (config.ack !== undefined) params.append("ack", config.ack);
|
||||
if (config.page) params.append("page", config.page);
|
||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||
if (config.status !== undefined) params.append("status", config.status);
|
||||
|
||||
@@ -58,13 +58,15 @@ class CheckController {
|
||||
|
||||
try {
|
||||
const { monitorId } = req.params;
|
||||
let { type, sortOrder, dateRange, filter, page, rowsPerPage, status } = req.query;
|
||||
let { type, sortOrder, dateRange, filter, ack, page, rowsPerPage, status } =
|
||||
req.query;
|
||||
const result = await this.db.getChecksByMonitor({
|
||||
monitorId,
|
||||
type,
|
||||
sortOrder,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
status,
|
||||
@@ -88,13 +90,14 @@ class CheckController {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let { sortOrder, dateRange, filter, page, rowsPerPage, status } = req.query;
|
||||
let { sortOrder, dateRange, filter, ack, page, rowsPerPage, status } = req.query;
|
||||
const { teamId } = req.user;
|
||||
|
||||
const checkData = await this.db.getChecksByTeam({
|
||||
sortOrder,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
teamId,
|
||||
@@ -109,7 +112,7 @@ class CheckController {
|
||||
}
|
||||
};
|
||||
|
||||
updateCheckStatus = async (req, res, next) => {
|
||||
ackCheck = async (req, res, next) => {
|
||||
try {
|
||||
await updateCheckStatusBodyValidation.validateAsync(req.body);
|
||||
} catch (error) {
|
||||
@@ -120,19 +123,20 @@ class CheckController {
|
||||
try {
|
||||
const { checkId } = req.params;
|
||||
const { ack } = req.body;
|
||||
const { teamId } = req.user;
|
||||
|
||||
const updatedCheck = await this.db.updateCheckStatus(checkId, ack);
|
||||
const updatedCheck = await this.db.ackCheck(checkId, teamId, ack);
|
||||
|
||||
return res.success({
|
||||
msg: this.stringService.checkUpdateStatus,
|
||||
data: updatedCheck,
|
||||
});
|
||||
} catch (error) {
|
||||
next(handleError(error, SERVICE_NAME, "updateCheckStatus"));
|
||||
next(handleError(error, SERVICE_NAME, "ackCheck"));
|
||||
}
|
||||
};
|
||||
|
||||
updateAllChecksStatus = async (req, res, next) => {
|
||||
ackAllChecks = async (req, res, next) => {
|
||||
try {
|
||||
await updateCheckStatusParamValidation.validateAsync(req.params);
|
||||
await updateAllChecksStatusBodyValidation.validateAsync(req.body);
|
||||
@@ -142,17 +146,18 @@ class CheckController {
|
||||
}
|
||||
|
||||
try {
|
||||
const { monitorId, target } = req.params;
|
||||
const { monitorId, path } = req.params;
|
||||
const { ack } = req.body;
|
||||
const { teamId } = req.user;
|
||||
|
||||
const updatedChecks = await this.db.updateAllChecksStatus(monitorId, ack, target);
|
||||
const updatedChecks = await this.db.ackAllChecks(monitorId, teamId, ack, path);
|
||||
|
||||
return res.success({
|
||||
msg: this.stringService.checkUpdateStatus,
|
||||
data: updatedChecks,
|
||||
});
|
||||
} catch (error) {
|
||||
next(handleError(error, SERVICE_NAME, "updateAllChecksStatus"));
|
||||
next(handleError(error, SERVICE_NAME, "ackAllChecks"));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ const getChecksByMonitor = async ({
|
||||
sortOrder,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
status,
|
||||
@@ -75,6 +76,7 @@ const getChecksByMonitor = async ({
|
||||
const matchStage = {
|
||||
monitorId: ObjectId.createFromHexString(monitorId),
|
||||
...(typeof status !== "undefined" && { status }),
|
||||
...(typeof ack !== "undefined" && { ack: ack === "true" ? true : false }),
|
||||
...(dateRangeLookup[dateRange] && {
|
||||
createdAt: {
|
||||
$gte: dateRangeLookup[dateRange],
|
||||
@@ -153,6 +155,7 @@ const getChecksByTeam = async ({
|
||||
sortOrder,
|
||||
dateRange,
|
||||
filter,
|
||||
ack,
|
||||
page,
|
||||
rowsPerPage,
|
||||
teamId,
|
||||
@@ -165,6 +168,7 @@ const getChecksByTeam = async ({
|
||||
const matchStage = {
|
||||
teamId: ObjectId.createFromHexString(teamId),
|
||||
status: status,
|
||||
...(typeof ack !== "undefined" && { ack: ack === "true" ? true : false }),
|
||||
...(dateRangeLookup[dateRange] && {
|
||||
createdAt: {
|
||||
$gte: dateRangeLookup[dateRange],
|
||||
@@ -242,14 +246,15 @@ const getChecksByTeam = async ({
|
||||
* Update the acknowledgment status of a check
|
||||
* @async
|
||||
* @param {string} checkId - The ID of the check to update
|
||||
* @param {string} teamId - The ID of the team
|
||||
* @param {boolean} ack - The acknowledgment status to set
|
||||
* @returns {Promise<Check>}
|
||||
* @throws {Error}
|
||||
*/
|
||||
const updateCheckStatus = async (checkId, ack) => {
|
||||
const ackCheck = async (checkId, teamId, ack) => {
|
||||
try {
|
||||
const updatedCheck = await Check.findOneAndUpdate(
|
||||
{ _id: checkId },
|
||||
{ _id: checkId, teamId: teamId },
|
||||
{ $set: { ack, ackAt: new Date() } },
|
||||
{ new: true }
|
||||
);
|
||||
@@ -261,7 +266,7 @@ const updateCheckStatus = async (checkId, ack) => {
|
||||
return updatedCheck;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "updateCheckStatus";
|
||||
error.method = "ackCheck";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -271,20 +276,20 @@ const updateCheckStatus = async (checkId, ack) => {
|
||||
* @async
|
||||
* @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')
|
||||
* @param {string} path - The path type ('monitor' or 'team')
|
||||
* @returns {Promise<number>}
|
||||
* @throws {Error}
|
||||
*/
|
||||
const updateAllChecksStatus = async (id, ack, target) => {
|
||||
const ackAllChecks = async (monitorId, teamId, ack, path) => {
|
||||
try {
|
||||
const updatedChecks = await Check.updateMany(
|
||||
target === "monitor" ? { monitorId: id } : { teamId: id },
|
||||
path === "monitor" ? { monitorId } : { teamId },
|
||||
{ $set: { ack, ackAt: new Date() } }
|
||||
);
|
||||
return updatedChecks.modifiedCount;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "updateAllChecksStatus";
|
||||
error.method = "ackAllChecks";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
@@ -370,8 +375,8 @@ export {
|
||||
createChecks,
|
||||
getChecksByMonitor,
|
||||
getChecksByTeam,
|
||||
updateCheckStatus,
|
||||
updateAllChecksStatus,
|
||||
ackCheck,
|
||||
ackAllChecks,
|
||||
deleteChecks,
|
||||
deleteChecksByTeamId,
|
||||
updateChecksTTL,
|
||||
|
||||
@@ -20,9 +20,9 @@ class CheckRoutes {
|
||||
|
||||
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
|
||||
|
||||
this.router.put("/:checkId", this.checkController.updateCheckStatus);
|
||||
this.router.put("/:checkId", this.checkController.ackCheck);
|
||||
|
||||
this.router.put("/:monitorId/:target", this.checkController.updateAllChecksStatus);
|
||||
this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks);
|
||||
|
||||
this.router.post(
|
||||
"/:monitorId",
|
||||
|
||||
@@ -294,8 +294,8 @@ const updateCheckStatusBodyValidation = joi.object({
|
||||
});
|
||||
|
||||
const updateCheckStatusParamValidation = joi.object({
|
||||
monitorId: joi.string(),
|
||||
target: joi.string().allow("monitor", "team"),
|
||||
monitorId: joi.string().optional(),
|
||||
path: joi.string().valid("monitor", "team").required(),
|
||||
});
|
||||
|
||||
const updateAllChecksStatusBodyValidation = joi.object({
|
||||
@@ -312,6 +312,7 @@ const getChecksQueryValidation = joi.object({
|
||||
limit: joi.number(),
|
||||
dateRange: joi.string().valid("recent", "hour", "day", "week", "month", "all"),
|
||||
filter: joi.string().valid("all", "down", "resolve"),
|
||||
ack: joi.boolean(),
|
||||
page: joi.number(),
|
||||
rowsPerPage: joi.number(),
|
||||
status: joi.boolean(),
|
||||
@@ -324,6 +325,7 @@ const getTeamChecksQueryValidation = joi.object({
|
||||
limit: joi.number(),
|
||||
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
||||
filter: joi.string().valid("all", "down", "resolve"),
|
||||
ack: joi.boolean(),
|
||||
page: joi.number(),
|
||||
rowsPerPage: joi.number(),
|
||||
status: joi.boolean(),
|
||||
|
||||
Reference in New Issue
Block a user