Skip to content
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

make orgs searchable #229

Merged
merged 1 commit into from
Oct 24, 2022
Merged

make orgs searchable #229

merged 1 commit into from
Oct 24, 2022

Conversation

jd2rogers2
Copy link
Contributor

Dev Summary

we need to be able to search for orgs/nonprofits
i've added this capability to our GET /api/organizations endpoint

Test Plan

repro steps:

  1. cd server run npm run seed:drop
  2. use psql or db mgmt software to see available orgs
select id, name, doing_business_as, description from organizations;
 id |                 name                 |          doing_business_as           |                   description                    
----+--------------------------------------+--------------------------------------+--------------------------------------------------
  7 | Childrens Home Society of Washington | Childrens Home Society of Washington | Support children from birth through age 12
  8 | Audobon Washington                   | Audobon Washington                   | Advocate for sustainable conservation management
  1. expect endpoint to still work without any query params. should get all orgs
jamesrogers 7:30:49 ~/Dev/neh/web-app/server $ curl 'localhost:3001/api/organizations' \
-H "Content-Type: application/json"
[{"id":8,"name":"Audobon Washington","doing_business_as":"Audobon Washington","description":"Advocate for sustainable conservation management","website":"https://wa.audubon.org/","address":"5902 Lake Washington Blvd S. Seattle, WA 98118","phone":"2066522444","city":"Seattle","state":"WA","ein":"12-3456789","nonprofit_classification":"charitable","image_url":"https://docs.nestjs.com/assets/logo-small.svg"},{"id":7,"name":"Childrens Home Society of Washington","doing_business_as":"Childrens Home Society of Washington","description":"Support children from birth through age 12","website":"https://www.childrenshomesociety.org/","address":"12360 LAKE CITY WAY NE, Seattle, WA 98125-5447","phone":"2066953200","city":"Seattle","state":"WA","ein":"12-3456788","nonprofit_classification":"charitable","image_url":"https://docs.nestjs.com/assets/logo-small.svg"}]%    
  1. expect search query param to only return orgs with matching name, dba, or description
    name:
jamesrogers 7:31:00 ~/Dev/neh/web-app/server $ curl 'localhost:3001/api/organizations?search=home' \
-H "Content-Type: application/json"
[{"id":7,"name":"Childrens Home Society of Washington","doing_business_as":"Childrens Home Society of Washington","description":"Support children from birth through age 12","website":"https://www.childrenshomesociety.org/","address":"12360 LAKE CITY WAY NE, Seattle, WA 98125-5447","phone":"2066953200","city":"Seattle","state":"WA","ein":"12-3456788","nonprofit_classification":"charitable","image_url":"https://docs.nestjs.com/assets/logo-small.svg"}]%       

description:

 jamesrogers 7:48:45 ~/Dev/neh/web-app $ curl 'localhost:3001/api/organizations?search=conservation' \
-H "Content-Type: application/json"
[{"id":8,"name":"Audobon Washington","doing_business_as":"Audobon Washington","description":"Advocate for sustainable conservation management","website":"https://wa.audubon.org/","address":"5902 Lake Washington Blvd S. Seattle, WA 98118","phone":"2066522444","city":"Seattle","state":"WA","ein":"12-3456789","nonprofit_classification":"charitable","image_url":"https://docs.nestjs.com/assets/logo-small.svg"}]%       
  1. expect limit and offset (pagination) params to work
    this gives us the second (offset 1 skips the first) of our subset when ordered by name
jamesrogers 7:31:05 ~/Dev/neh/web-app/server $ curl 'localhost:3001/api/organizations?search=washington&limit=1&offset=1' \
-H "Content-Type: application/json"
[{"id":7,"name":"Childrens Home Society of Washington","doing_business_as":"Childrens Home Society of Washington","description":"Support children from birth through age 12","website":"https://www.childrenshomesociety.org/","address":"12360 LAKE CITY WAY NE, Seattle, WA 98125-5447","phone":"2066953200","city":"Seattle","state":"WA","ein":"12-3456788","nonprofit_classification":"charitable","image_url":"https://docs.nestjs.com/assets/logo-small.svg"}]%            

Resources

@jd2rogers2 jd2rogers2 requested a review from esteban-gs October 24, 2022 14:50
@jd2rogers2 jd2rogers2 self-assigned this Oct 24, 2022
@jd2rogers2 jd2rogers2 linked an issue Oct 24, 2022 that may be closed by this pull request
@@ -47,6 +47,6 @@ export class Organization {
)
transactions: Transaction[];

@Column({ type: 'text', unique: true })
@Column({ type: 'text', nullable: true })
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed unique true because it was causing errors with seeding (because we use the same hardcoded img for multiple orgs)

added nullable true because we shouldn't require a profile img

@jd2rogers2
Copy link
Contributor Author

@esteban-gs going to merge this unreviewed as it's blocking @EtoKruto
feel free to leave comments and i will address them in a separate PR

@jd2rogers2 jd2rogers2 merged commit 88c1d10 into main Oct 24, 2022
@jd2rogers2 jd2rogers2 deleted the jd2rogers2/searchable_orgs branch October 24, 2022 14:54
@EtoKruto EtoKruto mentioned this pull request Oct 28, 2022
@jd2rogers2 jd2rogers2 mentioned this pull request Nov 7, 2022
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.

get searched orgs
1 participant