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

add /members/search endpoint #20

Open
OriHoch opened this issue Jan 18, 2024 · 4 comments
Open

add /members/search endpoint #20

OriHoch opened this issue Jan 18, 2024 · 4 comments
Assignees

Comments

@OriHoch
Copy link
Contributor

OriHoch commented Jan 18, 2024

this endpoint allows to search for members using some complex logic, it should return mk_individual_id of matching members, users can then use the new endpoint to get members details (#19)

name

search by name or part of name either "first last" or "last first", also in altnames

to allow searching by either first / last or last / first, do a search on all permutations:

name = 'Bibi Netanyahu'
name = name.split()
assert len(name) <= 4, 'too many name parts!'
import itertools
names = [' '.join(p) for p in itertools.permutations(name.split())]
for name in names:

select mk_individual_id from members_mk_individual
where mk_individual_first_name || ' ' || mk_individual_name like '%{name}%'

select mk_individual_id from (
    select mk_individual_id, jsonb_array_elements_text(altnames) altname from members_mk_individual
) a where altname like '%{name}%'  

committee

if value is an integer - do a simple search on committee id:

select mk_individual_id from members_mk_individual_committees where committee_id = {committee}

else - search on committee name:

select mk_individual_id from members_mk_individual_committees where committee_name like '%{committee}%'

faction

same as committee, just on the factions table

faction_chairperson

same as faction, just on the faction_chairperson table

govministries

same as faction, just on govministries table - search on govministry_id / gobministry_name

@bobiboMC
Copy link
Contributor

bobiboMC commented Jan 26, 2024

@OriHoch members_mk_individual_committees table is empty currently.

@bobiboMC
Copy link
Contributor

bobiboMC commented Jan 27, 2024

@OriHoch Also do you prefer one endpoint /members/search with optional parameters like name, faction etc or it can be numerous endpoints? I mean like /members/search/by-faction/{faction} , /members/search/by-committee/{committee} etc.

@OriHoch
Copy link
Contributor Author

OriHoch commented Jan 27, 2024

@OriHoch members_mk_individual_committees table is empty currently.

I'll check

@OriHoch Also do you prefer one endpoint /members/search with optional parameters like name, faction etc or it can be numerous endpoints? I mean like /members/search/by-faction/{faction} , /members/search/by-committee/{committee} etc.

I don't have a preference

@OriHoch
Copy link
Contributor Author

OriHoch commented Feb 26, 2024

fixed in #21 - assigning issue to me to test

@OriHoch OriHoch self-assigned this Feb 26, 2024
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

No branches or pull requests

2 participants