mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-05-18 23:48:43 -05:00
remove ack service and db methods
This commit is contained in:
@@ -178,41 +178,6 @@ class CheckModule {
|
||||
}
|
||||
};
|
||||
|
||||
ackCheck = async (checkId, teamId, ack) => {
|
||||
try {
|
||||
const updatedCheck = await CheckModel.findOneAndUpdate(
|
||||
{ _id: checkId, "metadata.teamId": teamId },
|
||||
{ $set: { ack, ackAt: new Date() } },
|
||||
{ new: true }
|
||||
);
|
||||
|
||||
if (!updatedCheck) {
|
||||
throw new Error("Check not found");
|
||||
}
|
||||
|
||||
return updatedCheck;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "ackCheck";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
ackAllChecks = async (monitorId, teamId, ack, path) => {
|
||||
try {
|
||||
const filter =
|
||||
path === "monitor"
|
||||
? { "metadata.monitorId": new mongoose.Types.ObjectId(monitorId) }
|
||||
: { "metadata.teamId": new mongoose.Types.ObjectId(teamId) };
|
||||
const updatedChecks = await CheckModel.updateMany(filter, { $set: { ack, ackAt: new Date() } });
|
||||
return updatedChecks.modifiedCount;
|
||||
} catch (error) {
|
||||
error.service = SERVICE_NAME;
|
||||
error.method = "ackAllChecks";
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
getChecksSummaryByTeamId = async ({ teamId }) => {
|
||||
try {
|
||||
const matchStage = {
|
||||
|
||||
@@ -174,33 +174,6 @@ class CheckService {
|
||||
return summary;
|
||||
};
|
||||
|
||||
ackCheck = async ({ checkId, teamId, ack }: { checkId: string; teamId: string; ack: any }) => {
|
||||
if (!checkId) {
|
||||
throw this.errorService.createBadRequestError("No check ID in request");
|
||||
}
|
||||
|
||||
if (!teamId) {
|
||||
throw this.errorService.createBadRequestError("No team ID in request");
|
||||
}
|
||||
|
||||
const updatedCheck = await this.db.checkModule.ackCheck(checkId, teamId, ack);
|
||||
return updatedCheck;
|
||||
};
|
||||
|
||||
ackAllChecks = async ({ monitorId, path, teamId, ack }: { monitorId: string; path: string; teamId: string; ack: any }) => {
|
||||
if (path === "monitor") {
|
||||
if (!monitorId) {
|
||||
throw this.errorService.createBadRequestError("No monitor ID in request");
|
||||
}
|
||||
|
||||
// For verificaiton, throws an error if monitor doesn't belong to team
|
||||
await this.monitorsRepository.findById(monitorId, teamId);
|
||||
}
|
||||
|
||||
const updatedChecks = await this.db.checkModule.ackAllChecks(monitorId, teamId, ack, path);
|
||||
return updatedChecks;
|
||||
};
|
||||
|
||||
deleteChecks = async ({ monitorId, teamId }: { monitorId: string; teamId: string }) => {
|
||||
if (!monitorId) {
|
||||
throw this.errorService.createBadRequestError("No monitor ID in request");
|
||||
|
||||
Reference in New Issue
Block a user