From dd6d3d4c4f2cd212fd0e1bfe7644d60db88790b1 Mon Sep 17 00:00:00 2001 From: Mae Beale Date: Sat, 24 Oct 2026 21:15:26 -0400 Subject: [PATCH 1/3] Let people search match an address's country With countries now stored as one dropdown name, searching by country finds everyone in it; contact-info search covered every other address column but country. Co-Authored-By: Claude Opus 5.5 (1M context) --- app/models/person.rb | 3 ++- .../2026-10-25-search-people-by-address-country.yml | 8 ++++++++ spec/models/person_spec.rb | 8 ++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 db/seeds/features/2026-10-25-search-people-by-address-country.yml diff --git a/app/models/person.rb b/app/models/person.rb index 407121cee7..bac126ad52 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/db/seeds/features/2026-10-25-search-people-by-address-country.yml b/db/seeds/features/2026-10-25-search-people-by-address-country.yml new file mode 100644 index 0000000000..3ed1e768a8 --- /dev/null +++ b/db/seeds/features/2026-10-25-search-people-by-address-country.yml @@ -0,0 +1,8 @@ +name: "Search people by their address country" +area: people +display_status: admin_facing +released_on: 2026-10-25 +pr_number: 2836 +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. diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index e13a437648..f396d48e8d 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -705,6 +705,14 @@ def phone_numbers expect(Person.search_name_email('alice@example')).to include(person_alice) 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) From 1d85979080f0598608a0fa5befee77336aaef918 Mon Sep 17 00:00:00 2001 From: Mae Beale Date: Sun, 25 Oct 2026 04:14:30 -0400 Subject: [PATCH 2/3] Link the people-search changelog entry to its own PR Co-Authored-By: Claude Opus 5.5 (1M context) --- .../features/2026-10-25-search-people-by-address-country.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds/features/2026-10-25-search-people-by-address-country.yml b/db/seeds/features/2026-10-25-search-people-by-address-country.yml index 3ed1e768a8..ffad6298ec 100644 --- a/db/seeds/features/2026-10-25-search-people-by-address-country.yml +++ b/db/seeds/features/2026-10-25-search-people-by-address-country.yml @@ -2,7 +2,7 @@ name: "Search people by their address country" area: people display_status: admin_facing released_on: 2026-10-25 -pr_number: 2836 +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. From 8b1dc5bf09068166c378d4ccc370c8101b562c65 Mon Sep 17 00:00:00 2001 From: Mae Beale Date: Sun, 25 Oct 2026 04:27:16 -0400 Subject: [PATCH 3/3] Search people's address country from the people index too #2825's contact-info box searches through search_contact, so country joins its attributes and the box's tooltip names it. Co-Authored-By: Claude Opus 5.5 (1M context) --- app/models/person.rb | 3 ++- app/views/people/_search_boxes.html.erb | 2 +- spec/models/person_spec.rb | 7 +++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index bac126ad52..3ab3122e48 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -221,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 diff --git a/app/views/people/_search_boxes.html.erb b/app/views/people/_search_boxes.html.erb index 03a845881a..26f47b790b 100644 --- a/app/views/people/_search_boxes.html.erb +++ b/app/views/people/_search_boxes.html.erb @@ -74,7 +74,7 @@ <%= 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." %> <% end %> diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index f396d48e8d..8b4ea334e2 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -705,6 +705,13 @@ 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')