diff --git a/backend/routes/dashboard/devices.js b/backend/routes/dashboard/devices.js index c076ff9..6c6f875 100644 --- a/backend/routes/dashboard/devices.js +++ b/backend/routes/dashboard/devices.js @@ -20,7 +20,7 @@ router.get('/devices', async (req, res) => { const flowPipeline = [ { $match: query }, { $group: { - _id: "$src_ip", + _id: { ip: "$src_ip", agent: "$agent_uuid" }, download: { $sum: "$download" }, upload: { $sum: "$upload" }, flows: { $sum: 1 }, @@ -32,7 +32,7 @@ router.get('/devices', async (req, res) => { { $sort: { download: -1 } }, { $project: { _id: 1, // needed for mapping later - ip_address: "$_id", + ip_address: "$_id.ip", download: 1, upload: 1, flows: 1, @@ -54,7 +54,7 @@ router.get('/devices', async (req, res) => { const pipeline = [ { $match: query }, { $sort: { timestamp: -1 } }, - { $group: { _id: "$ip_address", doc: { $first: "$$ROOT" } } }, + { $group: { _id: { ip: "$ip_address", agent: "$agent_uuid" }, doc: { $first: "$$ROOT" } } }, { $replaceRoot: { newRoot: "$doc" } }, { $sort: { timestamp: -1, download: -1 } } ];