Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions server/src/configs/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions server/src/configs/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions server/src/routes/rootRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])),
Expand Down
18 changes: 2 additions & 16 deletions src/components/QueryData.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
},
)
Expand Down