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 = () => {
|
||||
setMonitorUpdateTrigger((prev) => !prev);
|
||||
};
|
||||
const totalMonitors = monitorsSummary.totalMonitors;
|
||||
const hasMonitors = totalMonitors > 0;
|
||||
const totalMonitors = monitorsSummary?.totalMonitors ?? 0;
|
||||
const hasMonitors = monitorsSummary?.totalMonitors ?? 0;
|
||||
const canAddMonitor = isAdmin && hasMonitors;
|
||||
|
||||
return (
|
||||
|
||||
@@ -523,13 +523,6 @@ const getMonitorsByTeamId = async (req) => {
|
||||
|
||||
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([
|
||||
{ $match: matchStage },
|
||||
{
|
||||
@@ -563,6 +556,18 @@ const getMonitorsByTeamId = async (req) => {
|
||||
},
|
||||
],
|
||||
monitors: [
|
||||
...(filter !== undefined
|
||||
? [
|
||||
{
|
||||
$match: {
|
||||
$or: [
|
||||
{ name: { $regex: filter, $options: "i" } },
|
||||
{ url: { $regex: filter, $options: "i" } },
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{ $sort: sort },
|
||||
{ $skip: skip },
|
||||
...(rowsPerPage ? [{ $limit: rowsPerPage }] : []),
|
||||
|
||||
Reference in new issue
Block a user