mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-02 14:39:54 -05:00
ackStage Backword Compatible
This commit is contained in:
@@ -598,7 +598,6 @@ class NetworkService {
|
||||
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);
|
||||
return this.axiosInstance.get(`/checks/team?${params.toString()}`);
|
||||
};
|
||||
|
||||
@@ -610,12 +609,12 @@ class NetworkService {
|
||||
* @async
|
||||
* @param {Object} config - The configuration object.
|
||||
* @param {string} config.checkId - The ID of the check to update.
|
||||
* @param {boolean} config.status - The status to update the check to.
|
||||
* @param {boolean} config.ack - The acknowledgment to update the check to.
|
||||
* @returns {Promise<AxiosResponse>} The response from the axios PUT request.
|
||||
*
|
||||
*/
|
||||
async updateCheckStatus(config) {
|
||||
return this.axiosInstance.put(`/checks/${config.checkId}`, {
|
||||
return this.axiosInstance.put(`/checks/check/${config.checkId}`, {
|
||||
ack: config.ack,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class CheckController {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let { sortOrder, dateRange, filter, ack, page, rowsPerPage, status } = req.query;
|
||||
let { sortOrder, dateRange, filter, ack, page, rowsPerPage } = req.query;
|
||||
const { teamId } = req.user;
|
||||
|
||||
const checkData = await this.db.getChecksByTeam({
|
||||
@@ -101,7 +101,6 @@ class CheckController {
|
||||
page,
|
||||
rowsPerPage,
|
||||
teamId,
|
||||
status,
|
||||
});
|
||||
return res.success({
|
||||
msg: this.stringService.checkGet,
|
||||
|
||||
@@ -72,11 +72,17 @@ const getChecksByMonitor = async ({
|
||||
status = status === "true" ? true : status === "false" ? false : undefined;
|
||||
page = parseInt(page);
|
||||
rowsPerPage = parseInt(rowsPerPage);
|
||||
|
||||
const ackStage =
|
||||
ack === "true"
|
||||
? { ack: true }
|
||||
: { $or: [{ ack: false }, { ack: { $exists: false } }] };
|
||||
|
||||
// Match
|
||||
const matchStage = {
|
||||
monitorId: ObjectId.createFromHexString(monitorId),
|
||||
...(typeof status !== "undefined" && { status }),
|
||||
...(typeof ack !== "undefined" && { ack: ack === "true" }),
|
||||
...(typeof ack !== "undefined" && ackStage),
|
||||
...(dateRangeLookup[dateRange] && {
|
||||
createdAt: {
|
||||
$gte: dateRangeLookup[dateRange],
|
||||
@@ -159,16 +165,20 @@ const getChecksByTeam = async ({
|
||||
page,
|
||||
rowsPerPage,
|
||||
teamId,
|
||||
status,
|
||||
}) => {
|
||||
try {
|
||||
status = status === "true";
|
||||
page = parseInt(page);
|
||||
rowsPerPage = parseInt(rowsPerPage);
|
||||
|
||||
const ackStage =
|
||||
ack === "true"
|
||||
? { ack: true }
|
||||
: { $or: [{ ack: false }, { ack: { $exists: false } }] };
|
||||
|
||||
const matchStage = {
|
||||
teamId: ObjectId.createFromHexString(teamId),
|
||||
status: status,
|
||||
...(typeof ack !== "undefined" && { ack: ack === "true" }),
|
||||
teamId: new ObjectId(teamId),
|
||||
status: false,
|
||||
...(typeof ack !== "undefined" && ackStage),
|
||||
...(dateRangeLookup[dateRange] && {
|
||||
createdAt: {
|
||||
$gte: dateRangeLookup[dateRange],
|
||||
|
||||
@@ -22,7 +22,11 @@ class CheckRoutes {
|
||||
|
||||
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
|
||||
|
||||
this.router.put("/:checkId", verifyTeamAccess(Check, "checkId"), this.checkController.ackCheck);
|
||||
this.router.put(
|
||||
"/check/:checkId",
|
||||
verifyTeamAccess(Check, "checkId"),
|
||||
this.checkController.ackCheck
|
||||
);
|
||||
|
||||
this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks);
|
||||
|
||||
|
||||
@@ -328,7 +328,6 @@ const getTeamChecksQueryValidation = joi.object({
|
||||
ack: joi.boolean(),
|
||||
page: joi.number(),
|
||||
rowsPerPage: joi.number(),
|
||||
status: joi.boolean(),
|
||||
});
|
||||
|
||||
const deleteChecksParamValidation = joi.object({
|
||||
|
||||
Reference in New Issue
Block a user