diff --git a/backend/routes/dashboard/agents.js b/backend/routes/dashboard/agents.js index 217015e..0cb60e0 100644 --- a/backend/routes/dashboard/agents.js +++ b/backend/routes/dashboard/agents.js @@ -80,7 +80,7 @@ router.get('/agents', async (req, res) => { const isGlobalUser = effectiveRole === 'SUPER_ADMIN' || effectiveRole === 'EXECUTIVE'; const requestedSiteUuid = req.headers['x-backone-site-uuid']; - if (isGlobalUser && requestedSiteUuid) { + if (isGlobalUser && requestedSiteUuid && requestedSiteUuid !== 'all') { query.site_uuid = { $in: [requestedSiteUuid, 'global'] }; } else if (effectiveRole === 'TENANT_ADMIN') { query.site_uuid = { $in: [req.user.site_uuid, 'global'] }; diff --git a/backend/routes/dashboard/summary.js b/backend/routes/dashboard/summary.js index 33e0b4b..a1ca15b 100644 --- a/backend/routes/dashboard/summary.js +++ b/backend/routes/dashboard/summary.js @@ -40,9 +40,11 @@ router.get('/summary', async (req, res) => { } else { // ── Site-Level Summary (default) ───────────────────────────────────────── const agentQuery = { - site_uuid: baseWithoutTime.site_uuid || { $in: await Summary.distinct('site_uuid') }, agent_uuid: { $ne: null } }; + if (baseWithoutTime.site_uuid) { + agentQuery.site_uuid = baseWithoutTime.site_uuid; + } if (timeFilter) agentQuery.timestamp = timeFilter; const allAgentSummaries = await Summary.find(agentQuery).lean();