This commit is contained in:
Alex Holliday committed 2026-01-02 20:33:34 +00:00
1 parent 7f15811fdf
commit 8e6a8e5a06
7 files changed
+113 -114

No files matched your search

+22 -31
View File
@@ -189,48 +189,39 @@ class MonitorService implements IMonitorService {
.skip(skip)
.limit(rowsPerPage);
if (
type.length === 1 &&
(type[0] === "pagespeed" ||
type[0] === "infrastructure" ||
type[0] === "docker")
) {
const monitorIds = monitors.map((m) => m._id);
const monitorIds = monitors.map((m) => m._id);
const checks = await Check.aggregate([
{
$match: {
"metadata.monitorId": { $in: monitorIds },
},
const checks = await Check.aggregate([
{
$match: {
"metadata.monitorId": { $in: monitorIds },
},
{ $sort: { createdAt: -1 } },
{
$group: {
_id: "$metadata.monitorId",
latestChecks: { $push: "$$ROOT" },
},
},
{ $sort: { createdAt: -1 } },
{
$group: {
_id: "$metadata.monitorId",
latestChecks: { $push: "$$ROOT" },
},
{
$project: {
latestChecks: { $slice: [{ $ifNull: ["$latestChecks", []] }, 25] },
},
},
{
$project: {
latestChecks: { $slice: [{ $ifNull: ["$latestChecks", []] }, 25] },
},
]);
},
]);
const checksMap = new Map(
checks.map((c: any) => [c._id.toString(), c.latestChecks])
);
const checksMap = new Map(
checks.map((c: any) => [c._id.toString(), c.latestChecks])
);
monitors.forEach((monitor) => {
monitor.latestChecks = checksMap.get(monitor._id.toString()) || [];
});
}
return {
count: counts.total,
upCount: counts.upCount,
downCount: counts.downCount,
pausedCount: counts.pausedCount,
monitors,
checksMap: Object.fromEntries(checksMap),
};
};
@@ -786,7 +777,7 @@ class MonitorService implements IMonitorService {
status: {
$cond: {
if: { $eq: ["$status", "paused"] },
then: "initializing",
then: "resuming",
else: "paused",
},
},