change return type, set monitor status to default true value

This commit is contained in:
Alex Holliday committed 2024-08-30 10:17:02 -07:00
1 parent 0a11de47d7
commit ca7e06b8c5
1 file changed
+11 -4
+11 -4
View File
@@ -197,11 +197,18 @@ const deleteChecks = async (monitorId) => {
const deleteChecksByTeamId = async (teamId) => {
try {
const teamMonitors = await Monitor.find({ teamId: teamId });
teamMonitors.forEach(async (monitor) => {
await Check.deleteMany({ monitorId: monitor._id });
});
let totalDeletedCount = 0;
return true;
await Promise.all(
teamMonitors.map(async (monitor) => {
const result = await Check.deleteMany({ monitorId: monitor._id });
totalDeletedCount += result.deletedCount;
monitor.status = true;
await monitor.save();
})
);
return totalDeletedCount;
} catch (error) {
throw error;
}