-
Notifications
You must be signed in to change notification settings - Fork 1
feat: filter trails by activity + backfill trail activities #456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
+65
−3
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| -- Migration 075: Backfill and correct trail activities so the activity filter | ||
| -- (e.g. selecting "Biking") only surfaces trails that actually allow that activity. | ||
| -- | ||
| -- Three parts, all idempotent (guarded so re-runs are no-ops and so later admin | ||
| -- edits are not clobbered once a row no longer matches the known-bad state): | ||
| -- 1. Untagged trails -> 'Hiking' (most are CVNP/Metro foot trails). | ||
| -- 2. Drop 'Biking' from 11 footpaths that were mis-tagged as bikeable. | ||
| -- 3. Bikeable multi-use trails on the allowlist (Towpath, Bike & Hike, Gateway, | ||
| -- etc.) keep their existing 'Hiking, Biking' tags — no change needed. | ||
|
|
||
| BEGIN; | ||
|
|
||
| -- 1. Untagged trails -> 'Hiking' | ||
| UPDATE pois | ||
| SET primary_activities = 'Hiking' | ||
| WHERE 'trail' = ANY(poi_roles) | ||
| AND coalesce(deleted, false) = false | ||
| AND coalesce(nullif(trim(primary_activities), ''), '') = ''; | ||
|
|
||
| -- 2. Remove 'Biking' from hiking-only footpaths that were incorrectly tagged. | ||
| -- Element-wise: split on commas, drop the 'Biking' item, rejoin. Guarded by id list | ||
| -- + "still contains Biking" (Postgres word boundaries are \m \M, NOT \b), so it | ||
| -- fires once and re-runs as UPDATE 0. Gateway Trail (West Creek paved connector, | ||
| -- id 1018) and the paved/limestone multi-use trails are intentionally excluded. | ||
| UPDATE pois | ||
| SET primary_activities = ( | ||
| SELECT string_agg(trim(part), ', ') | ||
| FROM unnest(string_to_array(primary_activities, ',')) AS part | ||
| WHERE lower(trim(part)) <> 'biking' | ||
| ) | ||
| WHERE id IN (974, 1021, 1036, 1045, 1050, 1057, 1068, 1074, 1089, 1099, 1095) | ||
| AND primary_activities ~* '\mBiking\M'; | ||
|
|
||
| COMMIT; |
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Performance Bottleneck & Defensive Programming
isActivityFilterActiveis called insidetrailPassesActivityFilterfor every single trail feature (e.g., 179 trails) during map rendering and bounds tracking. SinceisActivityFilterActiveonly depends onvisibleTypesandiconConfig(which are constant for a given render pass), this results in redundant loops overiconConfighundreds of times per render. We can optimize this by caching the last computed result using reference equality checks onvisibleTypesandiconConfig.visibleTypesis a valid Set (or has ahasmethod) andfeatureis non-null before accessing their properties.