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
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:
committee
if value is an integer - do a simple search on committee id:
else - search on committee name:
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