Skip to content

Added location filter for members#25607

Open
maxineathos wants to merge 3 commits intoTryGhost:mainfrom
maxineathos:feat/add-location-filter
Open

Added location filter for members#25607
maxineathos wants to merge 3 commits intoTryGhost:mainfrom
maxineathos:feat/add-location-filter

Conversation

@maxineathos
Copy link
Copy Markdown

@maxineathos maxineathos commented Dec 3, 2025

fixes #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_FILTER to the Basic filters group in ghost/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

Low Risk
Low risk UI/filter definition change; it only adds a new filter option and relation options without altering core data flows or security-sensitive logic.

Overview
Adds a new Members “Location” filter (backed by geolocation) to the Basic filter group in Admin.

Introduces LOCATION_FILTER and a new CONTAINS_ONLY_RELATION_OPTIONS set (contains / does-not-contain / starts-with / ends-with), and exports both via the existing filters and relation-options indexes.

Reviewed by Cursor Bugbot for commit 9fd396d. Bugbot is set up for automated code reviews on this repo. Configure here.

- Introduced LOCATION_FILTER to the filter.js component for enhanced member filtering options.
- Updated index.js to export LOCATION_FILTER, ensuring it is available for use in the application.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 3, 2025

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_FILTER shape matches existing filters (label, name, valueType, relationOptions).
  • Confirm the property name geolocation is correct for member location storage.
  • Verify CONTAINS_ONLY_RELATION_OPTIONS contains the intended options (contains, does-not-contain, starts-with, ends-with).
  • Ensure export * from './location' and export * 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 | ✅ 5
✅ 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.
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.
Description check ✅ Passed The PR description clearly details the new Location filter feature, its purpose (filtering members by geolocation), implementation approach using text-based operators, and comprehensive testing instructions that match the changeset.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Replaced CONTAINS_RELATION_OPTIONS with CONTAINS_ONLY_RELATION_OPTIONS in the location filter component for improved filtering capabilities.
- Added new relation options in a separate file to enhance clarity and maintainability.
- Updated index.js to export the new relation options.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 6, 2026

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9fd396d. Configure here.

{label: 'does not contain', name: 'does-not-contain'},
{label: 'starts with', name: 'starts-with'},
{label: 'ends with', name: 'ends-with'}
];
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Near-duplicate relation options file instead of reusing existing

Low Severity

CONTAINS_ONLY_RELATION_OPTIONS is a near-duplicate of the existing CONTAINS_RELATION_OPTIONS, differing only in the absence of the is option. The PR description explicitly lists "is" (exact match) as a supported operator, and the analogous NAME_FILTER and EMAIL_FILTER (also valueType: 'string') both use CONTAINS_RELATION_OPTIONS. The LOCATION_FILTER could simply reuse CONTAINS_RELATION_OPTIONS instead of introducing a new nearly-identical constant and file.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9fd396d. Configure here.

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.

Filter members by location missing ?

1 participant