feat: fort map-data consumer — gyms (stations/pokestops/DNF to follow)#1228
Draft
jfberry wants to merge 15 commits into
Draft
feat: fort map-data consumer — gyms (stations/pokestops/DNF to follow)#1228jfberry wants to merge 15 commits into
jfberry wants to merge 15 commits into
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pure, dependency-free mapper that reproduces Pokestop.js's SQL-derived
{ available, conditions } filter-key shape from the structured tuples
returned by Golbat's GET /api/pokestop/available, so a future endpoint
consumer can replace the SQL block key-for-key.
…tardust Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Wires Pokestop.getAvailable() to Golbat's GET /api/pokestop/available
when a source has `mem` set (an endpoint source), using the Task 2
mapper to build the same {available, conditions} shape the SQL path
produces. Falls back to the existing SQL block unchanged on a
non-2xx response, a network/timeout error, or any thrown error;
MAD/DB sources (mem: '') skip the branch entirely and always run SQL.
Extracts the config-gated `fallbackRocketPokemonFiltering` a${id}-${form}
backfill (previously inline in the SQL rocketPokemon case) into a shared
applyRocketPokemonFallback() helper so both the endpoint and SQL paths
stay byte-identical. Adds a Pokestop.evalQuery static mirroring
Pokemon.evalQuery, since Pokestop extends Model directly and had no
endpoint-fetch helper of its own.
… SQL fallback path)
Endpoint sources (mem truthy) have no bound knex, so on
/api/pokestop/available failure the previous fallthrough to the SQL
block threw on this.query(), was swallowed by Promise.allSettled, and
silently contributed zero filter keys. Endpoint sources are now
endpoint-authoritative: on failure they return a clean empty
{ available: [], conditions: {} } instead of falling through, matching
Pokemon.getAvailable. The SQL block is reached only for mem:'' (DB/MAD)
sources.
A source with both a Golbat endpoint and DB creds now registers the endpoint AND builds a knex connection: migrated queries (Pokestop getAvailable) use the endpoint, un-migrated ones (getAll/getOne/search/ submissions) fall back to this.query() on the bound DB — so a Golbat pokestop endpoint no longer breaks map markers/popups/search. - DbManager: keep the knex connection for endpoint schemas that also carry DB creds; overlay mem/secret/httpAuth onto the schemaChecked context so isMad/has* flags survive. - Pokestop.getAvailable: on endpoint failure fall through to the SQL block (a dual source runs it on the bound knex; a pure-endpoint source throws and is dropped by allSettled) instead of returning empty. - types: ApiEndpoint.httpAuth typed; DbConnection gains optional endpoint/secret/httpAuth for the dual shape. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…the Golbat endpoint The DbManager fan-out logs "[DB] Querying available for Pokestop" before any source picks endpoint-vs-SQL, so it can't confirm the endpoint path ran. Add an [POKESTOPS] info line on the endpoint success path with the endpoint URL and per-category counts, so operators can positively confirm the pokestop available list came from Golbat (and by its absence, that it fell back to SQL). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
First slice of the reactmap fort-scan consumer: route Gym.getAll/getOne/ getAvailable through Golbat's fort endpoints with SQL fallback. Adds a shared evalScannerQuery util + gymAvailableMapper; getAll reuses secondaryFilter (no row mapper — ApiGymResult keys match) and adds filterRTree area handling. Stations/pokestops/DNF are follow-on plans on this branch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Routes ReactMap's fort map-data (markers, popups, filter lists) through Golbat's in-memory fort endpoints instead of SQL, with automatic SQL fallback — the Phase‑2 ReactMap consumer for the Golbat fort-scan work (Golbat draft UnownHash/Golbat#385). Stacks on #1227 (the pokestop-available consumer) and reuses its dual endpoint+DB source plumbing.
This PR is built in slices on one branch; the branch is a draft until all slices land and it's validated against a Golbat deploy.
Landed so far: gyms (match-all)
server/src/utils/evalScannerQuery.js(new) — shared endpoint-or-knex fetch helper (secret / HTTP-Basic auth,queryDebug), so gym/station consumers don't each re-copyPokemon.evalQuery.server/src/models/gymAvailableMapper.js(new) — pure mapper: Golbat/api/gym/available{teams,raids}→ thet/g/e/r+ raid-boss filter keys, reproducing the SQLGym.getAvailableoutput exactly.Gym.getAvailable→GET /api/gym/available, with SQL fallthrough on 503/error (dual source).Gym.getAll→POST /api/gym/scanmatch-all (filters: []); endpoint rows feed the existingsecondaryFilterunchanged (ApiGymResultfield names already match ReactMap's), with client-sideenabled/!deleted,hideOldGyms,power_up_level, andfilterRTreearea filtering; SQL fallback on any endpoint failure.Gym.getOne→GET /api/gym/id/{id}, with SQL fallback.Coming on this branch (follow-on slices)
Stations (match-all), pokestops (match-all, needs Golbat
with_incidents), then DNF filtering for all three (a fort filterBackendmirroringPkmnBackend) — the payoff phase that replacesfilters: []with translatedApiFortDnfFilter[]so Golbat does the narrowing.Design notes
getAll. Golbat'sApiGymResultuses ReactMap's own field names, so scan rows go straight intosecondaryFilter; only the aggregategetAvailableneeds a mapper.getAreaSqlis SQL-only, and (notably) thePokemon.getAllendpoint path applies no area filter — this consumer deliberately addsfilterRTreeon the fort endpoint path so area restrictions are enforced.membranch returns only on endpoint success and otherwise falls through to the existing SQL — a dual (endpoint + DB) source keeps working through a Golbat outage; a pure-endpoint source is dropped upstream. A Golbat network/timeout returnsundefined(distinguishable from an empty result) sogetAllfalls back rather than silently blanking markers.Badgetable, merged unchanged.Testing
Per repo convention there is no test framework and the maintainer opted out of TDD. Verified via
eslint+prettier(clean on all changed files), a throwawaynodegolden check on the mapper (exact key parity with the SQL path), reasoning against each SQL branch, and per-task + whole-branch subagent code review (two Important findings —getAllnet-error fallback and thepower_up_levelfilter — found and fixed).Live end-to-end validation is deferred until Golbat #385 is deployed (
fort_in_memoryon): confirm gym/raid markers, popups, and the gym filter list match the DB path, and area restrictions hold.Depends on
fort_in_memoryon.develop, this PR's diff includes feat(pokestop): consume Golbat /api/pokestop/available with endpoint-authoritative fallback (draft) #1227's commits.🤖 Generated with Claude Code