Merge pull request #579 from bluewave-labs/fix/be/monitor-details-bugfix

Minor bugfixes
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-08-09 11:52:13 -07:00
commit 6242650e5b
1 file changed
+6 -5
+6 -5
View File
@@ -81,14 +81,15 @@ const getMonitorById = async (req, res) => {
// If more than numToDisplay checks, pick every nth check // If more than numToDisplay checks, pick every nth check
if (numToDisplay !== undefined && checks && checks.length > numToDisplay) { if (numToDisplay !== undefined && checks && checks.length > numToDisplay) {
const n = Math.ceil(checks.length / numToDisplay); const n = Math.ceil(checks.length / numToDisplay);
checks = checks.filter((_, index) => index % n === 0); checks = checks.filter(
(_, index) => index % n === 0 || index === checks.length - 1
);
} }
// Normalize checks if requested // Normalize checks if requested
if (normalize) { if (normalize !== undefined) {
checks = NormalizeData(checks, 10, 100); checks = NormalizeData(checks, 1, 100);
} }
const notifications = await Notification.find({ monitorId: monitor._id }); const notifications = await Notification.find({ monitorId: monitor._id });
const monitorWithChecks = { ...monitor.toObject(), checks, notifications }; const monitorWithChecks = { ...monitor.toObject(), checks, notifications };
return monitorWithChecks; return monitorWithChecks;
@@ -148,7 +149,7 @@ const getMonitorsByUserId = async (req, res) => {
.limit(limit); .limit(limit);
//Normalize checks if requested //Normalize checks if requested
if (normalize === true) { if (normalize !== undefined) {
checks = NormalizeData(checks, 10, 100); checks = NormalizeData(checks, 10, 100);
} }