From 1e16ec6eb8da60b4f1995a3551b1337f00c803f3 Mon Sep 17 00:00:00 2001 From: dsutanto Date: Fri, 17 Jul 2026 12:33:44 +0700 Subject: [PATCH] Increase Limit query lookup applications and filter_apps = numeric --- backend/routes/appDetailsDpiHelper.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/backend/routes/appDetailsDpiHelper.js b/backend/routes/appDetailsDpiHelper.js index aa176b1..ade6701 100644 --- a/backend/routes/appDetailsDpiHelper.js +++ b/backend/routes/appDetailsDpiHelper.js @@ -44,21 +44,25 @@ async function populateAppCache(BASE_URL, token, siteUuid) { const headers = { 'x-api-key': token, 'Accept': 'application/json' }; if (siteUuid) headers['x-net-site'] = siteUuid; const res = await axios.get(`${BASE_URL}/lookup/applications`, { - headers, params: { settings_limit: 2000 }, timeout: 8000 + headers, params: { settings_limit: 5000 }, timeout: 20000 }); appLookupCache = {}; if (res.data && Array.isArray(res.data.data)) { res.data.data.forEach(a => { - if (!a.label || !a.id) return; + if (!a.id) return; + const label = (a.label || '').trim(); + if (!label) return; let domain = null; if (a.home_page?.url) { domain = a.home_page.url.replace(/^https?:\/\/(www\.)?/, '').split('/')[0]; } else if (a.domain_list?.length > 0) { domain = a.domain_list[0].label; } else { - domain = a.label.toLowerCase(); + domain = label.toLowerCase(); } - appLookupCache[a.label.toLowerCase()] = { id: a.id, label: a.label, domain }; + const entry = { id: a.id, label, domain }; + appLookupCache[label.toLowerCase()] = entry; + if (a.tag) appLookupCache[a.tag.toLowerCase()] = entry; }); } console.log(`[AppDetailsDpiHelper] App cache: ${Object.keys(appLookupCache).length} apps`); @@ -92,12 +96,12 @@ async function fetchFromDpiApi(label, agentUuid, timeRange, token, siteUuid) { const params = { filter_interval: timeRangeToMinutes(timeRange), - filter_applications: `["${appInfo.id}"]`, + filter_applications: `[${appInfo.id}]`, settings_limit: 10000 }; if (agentUuid && agentMapCache?.[agentUuid]) { - params.filter_agents = `[${agentMapCache[agentUuid]}]`; + params.filter_agents = `["${agentMapCache[agentUuid]}"]`; } const [dlRes, ulRes] = await Promise.all([