diff --git a/server/src/configs/custom-environment-variables.json b/server/src/configs/custom-environment-variables.json index 17a45b7a6..970c28d2c 100644 --- a/server/src/configs/custom-environment-variables.json +++ b/server/src/configs/custom-environment-variables.json @@ -45,6 +45,48 @@ "__format": "number" } }, + "polling": { + "devices": { + "__name": "API_POLLING_DEVICES", + "__format": "number" + }, + "gyms": { + "__name": "API_POLLING_GYMS", + "__format": "number" + }, + "nests": { + "__name": "API_POLLING_NESTS", + "__format": "number" + }, + "pokemon": { + "__name": "API_POLLING_POKEMON", + "__format": "number" + }, + "pokestops": { + "__name": "API_POLLING_POKESTOPS", + "__format": "number" + }, + "portals": { + "__name": "API_POLLING_PORTALS", + "__format": "number" + }, + "scanAreas": { + "__name": "API_POLLING_SCAN_AREAS", + "__format": "number" + }, + "scanCells": { + "__name": "API_POLLING_SCAN_CELLS", + "__format": "number" + }, + "submissionCells": { + "__name": "API_POLLING_SUBMISSION_CELLS", + "__format": "number" + }, + "weather": { + "__name": "API_POLLING_WEATHER", + "__format": "number" + } + }, "queryUpdateHours": { "pokemon": { "__name": "API_QUERY_UPDATE_HOURS_POKEMON", diff --git a/server/src/configs/default.json b/server/src/configs/default.json index 30eb5ad33..14b2e121a 100644 --- a/server/src/configs/default.json +++ b/server/src/configs/default.json @@ -18,6 +18,18 @@ "time": 60, "requests": 1000 }, + "polling": { + "devices": 10, + "gyms": 10, + "nests": 300, + "pokemon": 20, + "pokestops": 300, + "portals": 300, + "scanAreas": 10000, + "scanCells": 10, + "submissionCells": 500, + "weather": 30 + }, "queryUpdateHours": { "pokemon": 0.5, "quests": 1, diff --git a/server/src/routes/rootRouter.js b/server/src/routes/rootRouter.js index 751910d33..f3c0d5647 100644 --- a/server/src/routes/rootRouter.js +++ b/server/src/routes/rootRouter.js @@ -112,6 +112,7 @@ rootRouter.get('/settings', async (req, res) => { ...config.map, ...config.multiDomainsObj[req.headers.host], excludeList: config.authentication.excludeFromTutorial, + polling: config.api.polling, }, localeSelection: Object.fromEntries(config.map.localeSelection.map(l => [l, { name: l }])), tileServers: Object.fromEntries(config.tileServers.map(s => [s.name, s])), diff --git a/src/components/QueryData.jsx b/src/components/QueryData.jsx index 1dc17c7d1..317cce40d 100644 --- a/src/components/QueryData.jsx +++ b/src/components/QueryData.jsx @@ -10,20 +10,6 @@ import ActiveWeather from './layout/general/ActiveWeather' const filterSkipList = ['filter', 'enabled', 'legacy'] -const getPolling = category => { - switch (category) { - case 'devices': - case 'gyms': - case 'scanCells': - return 10 * 1000 - case 'pokemon': - return 20 * 1000 - case 'pokestops': return 5 * 60 * 1000 - case 'weather': return 30 * 1000 - default: return 10 * 60 * 1000 - } -} - export default function QueryData({ bounds, onMove, map, tileStyle, clusteringRules, config, params, isMobile, category, filters, staticFilters, staticUserSettings, sizeKey, @@ -83,14 +69,14 @@ export default function QueryData({ const { data, previousData, refetch, error } = useQuery( Query[category](filters, perms, map.getZoom(), clusteringRules.zoomLevel), { - context: { timeout: getPolling(category) }, + context: { timeout: (config.polling[category] || 10) * 1000 }, variables: { ...bounds, filters: trimFilters(filters), version: inject.VERSION, }, fetchPolicy: active ? 'cache-first' : 'cache-only', - pollInterval: getPolling(category), + pollInterval: (config.polling[category] || 10) * 1000, skip: !active, }, )