mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-13 05:09:51 -06:00
Merge pull request #514 from bluewave-labs/feat/be/add-notifications-to-monitors
Add notifications to monitors before returning
This commit is contained in:
@@ -2,6 +2,7 @@ const Monitor = require("../../../models/Monitor");
|
||||
const Check = require("../../../models/Check");
|
||||
const PageSpeedCheck = require("../../../models/PageSpeedCheck");
|
||||
const { errorMessages } = require("../../../utils/messages");
|
||||
const Notification = require("../../../models/Notification");
|
||||
|
||||
/**
|
||||
* Get all monitors
|
||||
@@ -63,7 +64,8 @@ const getMonitorById = async (req, res) => {
|
||||
createdAt: sortOrder,
|
||||
})
|
||||
.limit(limit);
|
||||
const monitorWithChecks = { ...monitor.toObject(), checks };
|
||||
const notifications = await Notification.find({ monitorId: monitor._id });
|
||||
const monitorWithChecks = { ...monitor.toObject(), checks, notifications };
|
||||
return monitorWithChecks;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
@@ -119,7 +121,12 @@ const getMonitorsByUserId = async (req, res) => {
|
||||
createdAt: sortOrder,
|
||||
})
|
||||
.limit(limit);
|
||||
return { ...monitor.toObject(), checks };
|
||||
|
||||
// Get notifications
|
||||
const notifications = await Notification.find({
|
||||
monitorId: monitor._id,
|
||||
});
|
||||
return { ...monitor.toObject(), checks, notifications };
|
||||
})
|
||||
);
|
||||
return monitorsWithChecks;
|
||||
|
||||
Reference in New Issue
Block a user