CAVaccineInventory / vial

The Django application powering calltheshots.us
https://vial.calltheshots.us
MIT License
13 stars 1 forks source link

Initial /api/searchLocations API #367

Closed simonw closed 3 years ago

simonw commented 3 years ago

We need a basic search API with the following features:

This issue is to get a basic framework up and running with those features. Will be adding plenty more features later on as and when we need them.

simonw commented 3 years ago

Initial design:

GET /api/searchLocations

Arguments:

simonw commented 3 years ago

Default JSON shape will be:

{
  "results": [
    {"id": "...", "name": "..."},
    {"id": "...", "name": "..."},
    {"id": "...", "name": "..."}
  ],
  "total": 1023
}

This leaves room to add extra keys for things like pagination later.

simonw commented 3 years ago

This will start out unauthenticated but we may want to start requiring Authorization: Bearer xxx authentication later on, especially for expensive operations like ?all=1.

simonw commented 3 years ago

Now live on staging, docs here: https://vial-staging.calltheshots.us/api/docs#get-apisearchlocations

simonw commented 3 years ago

Concordances are now populated, so this API can grow options to search by concordance ID reference.

simonw commented 3 years ago

For concordance filtering this works:

locations = Location.objects.filter(
    concordances__in=ConcordanceIdentifier.objects.filter(
      Q(authority = 'cvs', identifier='#11344') | Q(authority = 'google_places', identifier='ChIJ3S7I3CE9hYARLpUyyZ21Q2A')
    )
)
simonw commented 3 years ago

I'm going to try and get the streaming option to work next. I'm bumping the lat/lon/radius thing to another ticket.

simonw commented 3 years ago

New feature demos:

simonw commented 3 years ago
simonw commented 3 years ago

?all=1 is now live on staging!

curl 'https://vial-staging.calltheshots.us/api/searchLocations?all=1' > /tmp/wat.json

... that seemed to work! It gave me a 8MB JSON file with 10,562 locations in it

~ % cat /tmp/wat.json| jq .results | jq length
10562