move filtering to the monitors facet
This commit is contained in:
1 parent
62541f3fdd
commit
40fbe4a822
2 files changed
+14
-9
No files matched your search
@@ -137,8 +137,8 @@ const UptimeMonitors = () => {
|
|||||||
const triggerUpdate = () => {
|
const triggerUpdate = () => {
|
||||||
setMonitorUpdateTrigger((prev) => !prev);
|
setMonitorUpdateTrigger((prev) => !prev);
|
||||||
};
|
};
|
||||||
const totalMonitors = monitorsSummary.totalMonitors;
|
const totalMonitors = monitorsSummary?.totalMonitors ?? 0;
|
||||||
const hasMonitors = totalMonitors > 0;
|
const hasMonitors = monitorsSummary?.totalMonitors ?? 0;
|
||||||
const canAddMonitor = isAdmin && hasMonitors;
|
const canAddMonitor = isAdmin && hasMonitors;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -523,13 +523,6 @@ const getMonitorsByTeamId = async (req) => {
|
|||||||
|
|
||||||
const sort = { [field]: order === "asc" ? 1 : -1 };
|
const sort = { [field]: order === "asc" ? 1 : -1 };
|
||||||
|
|
||||||
if (filter !== undefined) {
|
|
||||||
matchStage.$or = [
|
|
||||||
{ name: { $regex: filter, $options: "i" } },
|
|
||||||
{ url: { $regex: filter, $options: "i" } },
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
const results = await Monitor.aggregate([
|
const results = await Monitor.aggregate([
|
||||||
{ $match: matchStage },
|
{ $match: matchStage },
|
||||||
{
|
{
|
||||||
@@ -563,6 +556,18 @@ const getMonitorsByTeamId = async (req) => {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
monitors: [
|
monitors: [
|
||||||
|
...(filter !== undefined
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
$match: {
|
||||||
|
$or: [
|
||||||
|
{ name: { $regex: filter, $options: "i" } },
|
||||||
|
{ url: { $regex: filter, $options: "i" } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
: []),
|
||||||
{ $sort: sort },
|
{ $sort: sort },
|
||||||
{ $skip: skip },
|
{ $skip: skip },
|
||||||
...(rowsPerPage ? [{ $limit: rowsPerPage }] : []),
|
...(rowsPerPage ? [{ $limit: rowsPerPage }] : []),
|
||||||
|
|||||||
Reference in new issue
Block a user