optimizations

This commit is contained in:
Alex Holliday
2024-09-17 09:37:24 +08:00
parent 204e0bbf40
commit b0942fdcab
+3 -4
View File
@@ -150,7 +150,6 @@ const getTeamChecks = async (req) => {
// Get monitorIDs
const userMonitors = await Monitor.find({ teamId: teamId }).select("_id");
const monitorIds = userMonitors.map((monitor) => monitor._id);
//Build check query
// Default limit to 0 if not provided
@@ -158,7 +157,7 @@ const getTeamChecks = async (req) => {
// Default sort order is newest -> oldest
sortOrder = sortOrder === "asc" ? 1 : -1;
checksQuery = { monitorId: { $in: monitorIds } };
checksQuery = { monitorId: { $in: userMonitors } };
if (filter !== undefined) {
checksQuery.status = false;
@@ -191,8 +190,8 @@ const getTeamChecks = async (req) => {
const checks = await Check.find(checksQuery)
.skip(skip)
.limit(rowsPerPage)
.sort({ createdAt: sortOrder });
.sort({ createdAt: sortOrder })
.select(["monitorId", "status", "responseTime", "statusCode", "message"]);
return { checksCount, checks };
};