Update getMonitorsByTeamid to use attached notifications

This commit is contained in:
Alex Holliday committed 2024-08-30 18:00:04 -07:00
1 parent 5b140198d6
commit 68b50a3059
2 files changed
+4 -7

No files matched your search

+3 -1
View File
@@ -205,12 +205,14 @@ const createMonitor = async (req, res, next) => {
const monitor = await req.db.createMonitor(req, res);
if (notifications && notifications.length !== 0) {
await Promise.all(
const setNotifications = await Promise.all(
notifications.map(async (notification) => {
notification.monitorId = monitor._id;
await req.db.createNotification(notification);
})
);
monitor.notifications = setNotifications;
await monitor.save();
}
// Add monitor to job queue
req.jobQueue.addJob(monitor._id, monitor);
+1 -6
View File
@@ -346,12 +346,7 @@ const getMonitorsByTeamId = async (req, res) => {
if (normalize !== undefined) {
checks = NormalizeData(checks, 10, 100);
}
// Get notifications
const notifications = await Notification.find({
monitorId: monitor._id,
});
return { ...monitor.toObject(), checks, notifications };
return { ...monitor.toObject(), checks };
})
);
return monitorsWithChecks;