add array of all monitors to response for search
This commit is contained in:
1 parent
af8f3a0351
commit
367d3602c8
1 file changed
+13
-3
@@ -545,6 +545,15 @@ const getMonitorsByTeamId = async (req) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
monitors: [
|
monitors: [
|
||||||
|
{ $sort: sort },
|
||||||
|
{
|
||||||
|
$project: {
|
||||||
|
_id: 1,
|
||||||
|
name: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
filteredMonitors: [
|
||||||
...(filter !== undefined
|
...(filter !== undefined
|
||||||
? [
|
? [
|
||||||
{
|
{
|
||||||
@@ -657,20 +666,21 @@ const getMonitorsByTeamId = async (req) => {
|
|||||||
{
|
{
|
||||||
$project: {
|
$project: {
|
||||||
summary: { $arrayElemAt: ["$summary", 0] },
|
summary: { $arrayElemAt: ["$summary", 0] },
|
||||||
|
filteredMonitors: 1,
|
||||||
monitors: 1,
|
monitors: 1,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let { monitors, summary } = results[0];
|
let { monitors, filteredMonitors, summary } = results[0];
|
||||||
monitors = monitors.map((monitor) => {
|
filteredMonitors = filteredMonitors.map((monitor) => {
|
||||||
if (!monitor.checks) {
|
if (!monitor.checks) {
|
||||||
return monitor;
|
return monitor;
|
||||||
}
|
}
|
||||||
monitor.checks = NormalizeData(monitor.checks, 10, 100);
|
monitor.checks = NormalizeData(monitor.checks, 10, 100);
|
||||||
return monitor;
|
return monitor;
|
||||||
});
|
});
|
||||||
return { monitors, summary };
|
return { monitors, filteredMonitors, summary };
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user