Skip to content

Commit f7c95bb

Browse files
committed
fix: fix syntax error in log aggregation pipeline
1 parent 9298d90 commit f7c95bb

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

apps/dashboard-api/src/controllers/project.controller.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -338,29 +338,29 @@ module.exports.getAllProject = async (req, res) => {
338338
.lean();
339339

340340
const projectIds = projects.map(p => p._id);
341-
const recentLogs = await Log.aggregate([
341+
const recentLogs = await Log.aggregate([
342342
{ $match: { projectId: { $in: projectIds } } },
343343
{ $sort: { timestamp: -1 } },
344344
{
345-
$group: {
346-
_id: "$projectId",
347-
logs: { $topN: { n: 100, sortBy: { timestamp: -1 }, output: { status: "$status" } } }
348-
}
349-
},
350-
{
351-
$project: {
352-
errorCount: {
353-
$size: {
354-
$filter: { input: "$logs", as: "l", cond: { $gte: ["$$l.status", 400] } } // cap to last 100 logs per project
355-
}
356-
},
357-
successCount: {
358-
$size: {
359-
$filter: { input: "$logs", as: "l", cond: { $lt: ["$$l.status", 400] } }
345+
$group: {
346+
_id: "$projectId",
347+
logs: { $topN: { n: 100, sortBy: { timestamp: -1 }, output: { status: "$status" } } }
348+
}
349+
},
350+
{
351+
$project: {
352+
errorCount: {
353+
$size: {
354+
$filter: { input: "$logs", as: "l", cond: { $gte: ["$$l.status", 400] } }
355+
}
356+
},
357+
successCount: {
358+
$size: {
359+
$filter: { input: "$logs", as: "l", cond: { $lt: ["$$l.status", 400] } }
360+
}
360361
}
361362
}
362363
}
363-
}
364364
]);
365365

366366
const logsMap = recentLogs.reduce((acc, log) => {

0 commit comments

Comments
 (0)