From 35f1838c4ed93e4342d29e355e59008432b07f16 Mon Sep 17 00:00:00 2001 From: ypratama Date: Tue, 1 Sep 2026 11:10:33 +0700 Subject: [PATCH] Fix: Combro resolved remaining bugs in summary.js and agents.js where site_uuid all was mishandled causing empty overview dashboards --- backend/routes/dashboard/agents.js | 2 +- backend/routes/dashboard/summary.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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();