Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/models/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,14 @@ def known_email_2_type? = email_2_type.in?(CONTACT_TYPES)
attributes address_city: "addresses.city"
attributes address_state: "addresses.state"
attributes address_zip: "addresses.zip_code"
attributes address_country: "addresses.country"
attributes address_phone: "addresses.phone"

attributes all: [ :first_name, :legal_first_name, :last_name, :email, :email_2,
"user.first_name", "user.last_name", "user.email", "user.phone",
"contact_methods.value",
"addresses.street_address", "addresses.city", "addresses.state",
"addresses.zip_code", "addresses.phone" ]
"addresses.zip_code", "addresses.country", "addresses.phone" ]
options :all, type: :text, default: true, default_operator: :or
end

Expand All @@ -220,10 +221,11 @@ def known_email_2_type? = email_2_type.in?(CONTACT_TYPES)
attributes address_city: "addresses.city"
attributes address_state: "addresses.state"
attributes address_zip: "addresses.zip_code"
attributes address_country: "addresses.country"
attributes address_phone: "addresses.phone"
attributes all: [ "contact_methods.value",
"addresses.street_address", "addresses.city", "addresses.state",
"addresses.zip_code", "addresses.phone" ]
"addresses.zip_code", "addresses.country", "addresses.phone" ]
options :all, type: :text, default: true, default_operator: :or
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/people/_search_boxes.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<!-- Contact info (admin only) -->
<%= render "shared/filter_text", param: :contact_info, label: "Contact info", submit: true,
wrapper_class: "w-full",
tooltip: "Searches phone, address, city, state, and ZIP." %>
tooltip: "Searches phone, address, city, state, ZIP, and country." %>
</div>
</div>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
name: "Search people by their address country"
area: people
display_status: admin_facing
released_on: 2026-10-25
pr_number: 2837
summary: >-
The people search's contact info now matches the country on a person's address, so
typing "India" β€” or address_country:"South Africa" β€” finds the people who live there.
15 changes: 15 additions & 0 deletions spec/models/person_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,21 @@ def phone_numbers
expect(Person.search_name_email('alice@example')).to include(person_alice)
end

it 'search_contact matches an address country' do
create(:address, addressable: person_bob, country: 'South Africa')

expect(Person.search_contact('South Africa')).to contain_exactly(person_bob)
expect(Person.search_contact('address_country:"South Africa"')).to contain_exactly(person_bob)
end

it 'filters by contact_info matching an address country' do
create(:address, addressable: person_bob, country: 'South Africa')
create(:address, addressable: person_alice, country: 'India')

expect(Person.search_by_params(contact_info: 'address_country:"South Africa"')).to contain_exactly(person_bob)
expect(Person.search_by_params(contact_info: 'India')).to contain_exactly(person_alice)
end

it 'filters by shared_contact_info matching a full name' do
results = Person.search_by_params(shared_contact_info: 'Alice Smith')
expect(results).to include(person_alice)
Expand Down
Loading