Merge pull request #844 from bluewave-labs/fix/incidents-remove-checks
Remove checks from monitor query
This commit is contained in:
3 files changed
+11
-5
No files matched your search
@@ -28,7 +28,7 @@ const Incidents = () => {
|
|||||||
const res = await networkService.getMonitorsByTeamId(
|
const res = await networkService.getMonitorsByTeamId(
|
||||||
authState.authToken,
|
authState.authToken,
|
||||||
authState.user.teamId,
|
authState.user.teamId,
|
||||||
1,
|
-1,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
@@ -36,6 +36,7 @@ const Incidents = () => {
|
|||||||
null,
|
null,
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
console.log(res.data.data);
|
||||||
// Reduce to a lookup object for 0(1) lookup
|
// Reduce to a lookup object for 0(1) lookup
|
||||||
if (res?.data?.data?.monitors?.length > 0) {
|
if (res?.data?.data?.monitors?.length > 0) {
|
||||||
const monitorLookup = res.data.data.monitors.reduce((acc, monitor) => {
|
const monitorLookup = res.data.data.monitors.reduce((acc, monitor) => {
|
||||||
|
|||||||
@@ -271,7 +271,6 @@ const getMonitorsByTeamId = async (req, res, next) => {
|
|||||||
try {
|
try {
|
||||||
const teamId = req.params.teamId;
|
const teamId = req.params.teamId;
|
||||||
const monitors = await req.db.getMonitorsByTeamId(req, res);
|
const monitors = await req.db.getMonitorsByTeamId(req, res);
|
||||||
|
|
||||||
return res.json({
|
return res.json({
|
||||||
success: true,
|
success: true,
|
||||||
msg: successMessages.MONITOR_GET_BY_USER_ID(teamId),
|
msg: successMessages.MONITOR_GET_BY_USER_ID(teamId),
|
||||||
|
|||||||
@@ -373,12 +373,18 @@ const getMonitorsByTeamId = async (req, res) => {
|
|||||||
sortOrder = -1;
|
sortOrder = -1;
|
||||||
} else sortOrder = -1;
|
} else sortOrder = -1;
|
||||||
|
|
||||||
// This effectively removes limit, returning all checks
|
|
||||||
if (limit === undefined) limit = 0;
|
|
||||||
|
|
||||||
const monitors = await Monitor.find(monitorQuery)
|
const monitors = await Monitor.find(monitorQuery)
|
||||||
.skip(skip)
|
.skip(skip)
|
||||||
.limit(rowsPerPage);
|
.limit(rowsPerPage);
|
||||||
|
|
||||||
|
// Early return if limit is set to -1, indicating we don't want any checks
|
||||||
|
if (limit === "-1") {
|
||||||
|
return { monitors, monitorCount: monitorsCount };
|
||||||
|
}
|
||||||
|
|
||||||
|
// This effectively removes limit, returning all checks
|
||||||
|
if (limit === undefined) limit = 0;
|
||||||
|
|
||||||
// Map each monitor to include its associated checks
|
// Map each monitor to include its associated checks
|
||||||
const monitorsWithChecks = await Promise.all(
|
const monitorsWithChecks = await Promise.all(
|
||||||
monitors.map(async (monitor) => {
|
monitors.map(async (monitor) => {
|
||||||
|
|||||||
Reference in new issue
Block a user