Skip to content

feat(enchantedparks): bundle attraction locations for WoF + MA#211

Merged
cubehouse merged 2 commits into
mainfrom
fix/enchantedparks-attraction-locations
Jun 9, 2026
Merged

feat(enchantedparks): bundle attraction locations for WoF + MA#211
cubehouse merged 2 commits into
mainfrom
fix/enchantedparks-attraction-locations

Conversation

@cubehouse

Copy link
Copy Markdown
Member

Problem

After #210 landed and the Worlds of Fun / Michigan's Adventure migrations were committed, the wiki kept the per-ride coordinates that the SixFlags POI endpoint used to provide. But the EnchantedParks WordPress source has no per-attraction lat/lng — so every collector tick proposes deleting all 57+54 locations again, putting them right back into the moderation queue.

Rejecting them once doesn't fix it; they come back next tick.

Fix

Static JSON snapshot of the existing per-ride coordinates, bundled into the EnchantedParks base class:

  • src/parks/enchantedparks/locations/worldsoffun.json — 57 rides
  • src/parks/enchantedparks/locations/michigansadventure.json — 54 rides

Snapshot taken from the wiki right after migration, while the SixFlags POI-era locations were still preserved.

Subclasses opt in by setting this.attractionLocations = locations in the constructor. Base class looks up by normalized name (curly → straight ' + lowercase — the WP source uses curly, the wiki uses straight, so without normalization ~20% of names miss).

Coverage

Park Attractions emitted With location Unmatched
Worlds of Fun 57 57 ✓
Michigan's Adventure 54 52 "Family Lagoon", "Funland Farms" — area names, not present in wiki snapshot either, so no regression

Tests: npm test — 1187/1187 pass.

What's NOT in this PR

  • Valleyfair: already on EnchantedParks, also has its 49 locations preserved on the wiki. Same issue would apply, but the user has not flagged it (possibly because no collector tick has touched them since the original migration, or they're set via _user overrides). Trivial follow-up if it surfaces — pull the snapshot, drop in locations/valleyfair.json, two lines in the subclass.
  • New attractions added later by EP: these will land without coordinates until manually placed via moderation. One-time touch per ride, not a treadmill.

🤖 Generated with Claude Code

The EP WordPress source does not expose per-attraction lat/lng. Without
a location field on each emitted attraction, the collector proposes
deleting all existing coordinates on every tick — an infinite-rejection
loop on the moderation queue for the just-migrated Worlds of Fun and
Michigan's Adventure (57 + 54 attractions each).

Add a static JSON snapshot of the existing per-ride coordinates (taken
from the wiki right after the SixFlags-era data was preserved through
the migration) and wire it into the EnchantedParks base class.
Subclasses opt in by assigning `this.attractionLocations = locations`.

Name lookup folds curly apostrophe (’ U+2019) to straight (') and
lowercases — the WP source uses curly and the wiki snapshot uses
straight, which would otherwise lose ~20% of matches.

Verified:
- WoF: 57/57 attractions emit location
- MA:  52/54 attractions emit location (2 unmatched are area names
  "Family Lagoon" / "Funland Farms" not present in the wiki snapshot)
- Vitest: 1187/1187 pass

Future attractions added by EP later won't have coordinates until they
are placed manually via the moderation queue, but that's a one-time
touch per ride rather than an every-tick treadmill.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 9, 2026 21:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the EnchantedParks destination implementation to preserve per-attraction geo coordinates for parks whose WordPress source lacks ride-level lat/lng, preventing repeated “delete location” proposals on each collector tick (specifically for Worlds of Fun and Michigan’s Adventure).

Changes:

  • Add a base-class mechanism in EnchantedParks to optionally attach per-attraction location from a static snapshot, using normalized-name matching (curly ↔ straight apostrophes + lowercase).
  • Wire Worlds of Fun and Michigan’s Adventure subclasses to opt into that mechanism by importing bundled JSON snapshots and assigning this.attractionLocations.
  • Add static JSON snapshots for both parks’ attraction coordinates under src/parks/enchantedparks/locations/.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/parks/enchantedparks/enchantedparks.ts Adds optional attraction location snapshot support + name normalization and attaches locations to emitted attraction entities.
src/parks/enchantedparks/worldsoffun.ts Imports the bundled WoF snapshot and enables attraction-location attachment via this.attractionLocations.
src/parks/enchantedparks/michigansadventure.ts Imports the bundled MA snapshot and enables attraction-location attachment via this.attractionLocations.
src/parks/enchantedparks/locations/worldsoffun.json Bundled static snapshot of WoF attraction coordinates.
src/parks/enchantedparks/locations/michigansadventure.json Bundled static snapshot of MA attraction coordinates.

Comment on lines +204 to +208
protected lookupAttractionLocation(
rideName: string,
): {latitude: number; longitude: number} | undefined {
if (!this.attractionLocations) return undefined;
if (!this.normalizedLocations) {
Added unit tests for the new lookup path that drives whether an
emitted attraction retains its existing coordinates:
- curly ’ (U+2019) vs straight ' apostrophe match
- case-insensitive matching
- missing-name returns undefined
- no-snapshot returns undefined

Full suite 1191/1191 pass.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@cubehouse

Copy link
Copy Markdown
Member Author

Addressed on 2ae06a15: added 4 targeted unit tests in src/parks/enchantedparks/__tests__/enchantedparks.test.ts via a Probe subclass that exposes the protected lookupAttractionLocation — covers (1) curly ↔ straight apostrophe match, (2) case-insensitive matching, (3) undefined when name not in snapshot, (4) undefined when no snapshot configured.

Test suite: 1191/1191 pass.

cc @copilot-pull-request-reviewer

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Comment on lines 1 to +4
import {EnchantedParks} from './enchantedparks.js';
import {destinationController} from '../../destinationRegistry.js';
import type {DestinationConstructor} from '../../destination.js';
import locations from './locations/worldsoffun.json' with {type: 'json'};
Comment on lines 1 to +4
import {EnchantedParks} from './enchantedparks.js';
import {destinationController} from '../../destinationRegistry.js';
import type {DestinationConstructor} from '../../destination.js';
import locations from './locations/michigansadventure.json' with {type: 'json'};
@cubehouse

Copy link
Copy Markdown
Member Author

Re: the JSON-imports-don't-survive-build concerns — those don't apply here. Verified on a clean rebuild:

```
$ rm -rf dist && npm run build && ls dist/parks/enchantedparks/locations/
michigansadventure.json
worldsoffun.json

$ node --input-type=module -e "
import('./dist/parks/enchantedparks/locations/worldsoffun.json', {with:{type:'json'}})
.then(m => console.log('keys:', Object.keys(m.default).length))"
keys: 57
```

With `resolveJsonModule: true` in `tsconfig.json` (already enabled in this repo), `tsc` does copy JSON assets into the output tree alongside the compiled JS. Both location files land at `dist/parks/enchantedparks/locations/*.json` and load correctly at runtime. The published npm package picks them up automatically since `dist/` is the package's entry point.

cc @copilot-pull-request-reviewer

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@cubehouse cubehouse merged commit a5d4d8f into main Jun 9, 2026
6 checks passed
@cubehouse cubehouse deleted the fix/enchantedparks-attraction-locations branch June 9, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants