Added location filter for members
fixes https://github.com/TryGhost/Ghost/issues/25557
What does this PR do?
Adds the ability to filter members by location (geolocation) in the Ghost Admin dashboard.
Why is this needed?
Users with large member bases need to filter members by geographic location to:
- Identify and remove bot accounts that often originate from the same location
- Segment audiences by region for targeted content strategies
- Better understand the geographic distribution of their membership
How does it work?
The implementation adds a new "Location" filter option in the Basic filters group. Since geolocation is stored as a JSON string containing location data from GeoJS (country, city, region, etc.), the filter uses text-based operators:
- is - exact match
- contains - partial match (e.g., "Brazil", "California")
- does not contain - exclude matches
- starts with - prefix match
- ends with - suffix match
This allows administrators to filter members using queries like geolocation:~'United States' to find all members from a specific country.
Changes
- Added new filter definition:
ghost/admin/app/components/members/filters/location.js - Exported the filter in
ghost/admin/app/components/members/filters/index.js - Added
LOCATION_FILTERto the Basic filters group inghost/admin/app/components/members/filter.js
Testing
- Navigate to Members in Ghost Admin
- Click the Filter button
- Select "Location" from the filter dropdown
- Enter a location value (e.g., country name, city)
- Verify that members are filtered correctly based on their geolocation data
[!NOTE] Adds a "Location" (
geolocation) members filter with contains/starts/ends operators and integrates it into the Basic filters.
- Admin โ Members Filters:
- Add
LOCATION_FILTERforgeolocation(string) usingCONTAINS_ONLY_RELATION_OPTIONS.- Include
LOCATION_FILTERin Basic group incomponents/members/filter.js.- Relation Options:
- Add
CONTAINS_ONLY_RELATION_OPTIONS(contains,does-not-contain,starts-with,ends-with) and export viarelation-options/index.js.- Exports:
- Export
locationfilter fromcomponents/members/filters/index.js.Written by Cursor Bugbot for commit d073057bd8ece82bf4106664818b4d09edac7ca0. This will update automatically on new commits. Configure here.
[!NOTE]
Other AI code review bot(s) detected
CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.
Walkthrough
Adds location-based member filtering by introducing a new LOCATION_FILTER constant (label "Location", name geolocation, valueType: "string") that uses a newly added CONTAINS_ONLY_RELATION_OPTIONS. The new filter is re-exported from components/members/filters/index.js and included in the Basic filter group. A new relation-options module contains-only.js is added and re-exported from relation-options/index.js.
Estimated code review effort
๐ฏ 2 (Simple) | โฑ๏ธ ~10 minutes
- Check
LOCATION_FILTERshape matches existing filters (label, name, valueType, relationOptions). - Confirm the property name
geolocationis correct for member location storage. - Verify
CONTAINS_ONLY_RELATION_OPTIONScontains the intended options (contains, does-not-contain, starts-with, ends-with). - Ensure
export * from './location'andexport * from './contains-only'correctly expose the new exports. - Files to spot-check:
- ghost/admin/app/components/members/filters/location.js
- ghost/admin/app/components/members/filter.js
- ghost/admin/app/components/members/filters/relation-options/contains-only.js
- ghost/admin/app/components/members/filters/index.js
- ghost/admin/app/components/members/filters/relation-options/index.js
Pre-merge checks and finishing touches
โ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | โ Passed | The title accurately describes the main change: adding a location filter for members, which directly matches the primary objective of the PR. |
| Description check | โ Passed | The description comprehensively explains the change, its purpose, implementation details, and testing steps. It is clearly related to the changeset and provides context about the feature. |
| Linked Issues check | โ Passed | The PR successfully implements all coding requirements from issue #25557: adds location filter to Members UI with text-based operators (contains, does-not-contain, starts-with, ends-with) enabling member filtering by geolocation and bot account identification. |
| Out of Scope Changes check | โ Passed | All changes are directly scoped to implementing the location filter feature: new filter definition, exports, and integration into the Basic filters group. No unrelated modifications detected. |
| Docstring Coverage | โ Passed | No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. |
โจ Finishing touches
- [ ] ๐ Generate docstrings
๐งช Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
๐ Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
๐ฅ Commits
Reviewing files that changed from the base of the PR and between 70952a694cc6b60542ebf3cdaf91b49a8a498ffc and d073057bd8ece82bf4106664818b4d09edac7ca0.
๐ Files selected for processing (3)
ghost/admin/app/components/members/filters/location.js(1 hunks)ghost/admin/app/components/members/filters/relation-options/contains-only.js(1 hunks)ghost/admin/app/components/members/filters/relation-options/index.js(1 hunks)
๐ง Files skipped from review as they are similar to previous changes (1)
- ghost/admin/app/components/members/filters/location.js
โฐ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Cursor Bugbot
๐ Additional comments (2)
ghost/admin/app/components/members/filters/relation-options/index.js (1)
2-2: LGTM!The barrel export follows the established pattern and correctly exposes the new
contains-onlymodule.ghost/admin/app/components/members/filters/relation-options/contains-only.js (1)
1-6: Missing "is" operator mentioned in PR description.The PR description explicitly states the filter uses "text-based operators: is, contains, does not contain, starts with, and ends with." However, the implementation only includes 4 operators and is missing the "is" operator. Please verify whether:
- The "is" operator should be added to this array, or
- The PR description should be updated to reflect the actual operators supported
If "is" should be included, apply this diff:
export const CONTAINS_ONLY_RELATION_OPTIONS = [ + {label: 'is', name: 'is'}, {label: 'contains', name: 'contains'}, {label: 'does not contain', name: 'does-not-contain'}, {label: 'starts with', name: 'starts-with'}, {label: 'ends with', name: 'ends-with'} ];
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.