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

API Endpoints for getting contacts by type #9193

Closed
jkuester opened this issue Jun 21, 2024 · 2 comments · Fixed by #9311
Closed

API Endpoints for getting contacts by type #9193

jkuester opened this issue Jun 21, 2024 · 2 comments · Fixed by #9311
Assignees
Labels
Type: Feature Add something new
Milestone

Comments

@jkuester
Copy link
Contributor

Is your feature request related to a problem? Please describe.
As noted in #8889, getting the contacts of a specific type is needed for cht-user-managment.

Describe the solution you'd like

HTTP GET api/v1/person

HTTP GET api/v1/place?type=clinic

Endpoints should also accept the following query parameters to allow for paging through the data:

  • limit - default is 100
  • skip - default 0

When it comes to the cht-datasource api, things will be a bit interesting. On one hand, most consumers of the lib will not want to manually deal with paging, but instead we should return something like an async Iterable so the paging it completely abstracted away. However, the api code will need to be able to make a targeted request for a specific limit/skip since that is what it will be receiving as a request and for best performance we will need to be able to pass those though directly to the Couch view query... Perhaps we just provide both functions in cht-datasource:

  • One that takes limit/skip and returns an array of values.
  • One that just returns an Iterable - Under the hood, this would probably just use the first function, but wrap it up with a generator function or something.

Describe alternatives you've considered
Other ways to structure the API include:

  • api/v1/clinic
  • api/v1/place/clinic

However, these do not seem any more clear than just using a query parameter and are definitely less flexible.

@sugat009
Copy link
Member

sugat009 commented Jul 3, 2024

After a bit of assessment, I've decided to break this task down into smaller tasks in the following way.

  1. Add functionality of getting people with pagination in the cht-datasource. (Add functionality of getting people with pagination in cht-datasource #9237)
  2. Add functionality of getting people as an iterator in the cht-datasource. (Add functionality of getting people as an iterator in cht-datasource #9238)
  3. Add functionality of getting places with pagination in the cht-datasource. ( Add functionality of getting places with pagination in cht-datasource #9239)
  4. Add functionality of getting places as an iterator in the cht-datasource. ( Add functionality of getting places as an iterator in cht-datasource #9240)
  5. Add API api/v1/person. (Create API endpoint for getting people #9241)
  6. Add API api/v1/place?type=clinic (Create API endpoint for getting places with types #9242)

@sugat009
Copy link
Member

sugat009 commented Jul 3, 2024

I will be pushing each sub-task changes to this branch 9193-api-endpoints-for-getting-contacts-by-type.

sugat009 added a commit that referenced this issue Aug 9, 2024
sugat009 added a commit that referenced this issue Aug 12, 2024
sugat009 added a commit that referenced this issue Aug 23, 2024
…erables in cht-datasource (#9311)

Co-authored-by: Joshua Kuestersteffen <[email protected]>
@github-project-automation github-project-automation bot moved this from Todo to Done in Product Team Activities Aug 23, 2024
@sugat009 sugat009 moved this from Done to Todo in Product Team Activities Aug 23, 2024
sugat009 added a commit that referenced this issue Aug 23, 2024
sugat009 added a commit that referenced this issue Sep 2, 2024
…erables in cht-datasource (#9368)

Co-authored-by: Joshua Kuestersteffen <[email protected]>
@Benmuiruri Benmuiruri added this to the 4.12.0 milestone Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature Add something new
Projects
Status: Done
3 participants