IFRCGo/go-api

Add new surge alert filters to API

Closed this issue · 13 comments

We added a bunch of surge alert fields earlier this year from RRMS. I'm hoping we can make those accessible via the API for end users like myself. Per the documentation, it looks like there are several missing from what we added (as well as some that I believe were already there), including:

  • start (as well as start__gt, __gte, __lt, __lte)
  • molnix_status
  • message
  • country
  • molnix_tags - these have the new "groups" key that contain a bunch of keys i'd love to have access to, such as ROLES, LANGUAGE, SECTOR, rotation, etc.

Theoretically these fields are in the serializer: https://github.com/IFRCGo/go-api/blob/develop/notifications/serializers.py#L20
So they should be seen.
(The documentation is linked to GO API, so maybe the logged in status is needed to see the widest possible datasets.)
I can see these in the mentioned page:
kép
(The left side fields are just query (input) parameters.)

@szabozoltan69 thanks Zoltan, I see them in there too, but I can't seem to filter by them. For example, if I run GET https://goadmin.ifrc.org/api/v2/surge_alert/?molnix_id=2842 I still get 3600+ results. But if I try filtering with options listed in the documentation, say GET https://goadmin.ifrc.org/api/v2/surge_alert/?is_active=true, I do get filtered results.

Ok, so we should append the needed fields to the filterset, to this:
https://github.com/IFRCGo/go-api/blob/develop/notifications/drf_views.py#L23_L26

Is it ok if I add these?
molnix_id, molnix_status, start, message, country

is it possible to have it filter those molnix_tags too? or is the structure too complex?

I do it also, ok. :-)

FYI: Renamed the title of this ticket to "Add new surge alert filters to API" instead of "Add new surge alert fields to API" to make the requirement a bit clearer.

In local tests filtering is ok:

curl http://localhost:8000/api/v2/surge_alert/?country__iso3__in=HND,HUN\&molnix_tags=3  # gives 2
curl http://localhost:8000/api/v2/surge_alert/?country__iso3__in=HND,HUN\&molnix_tag_names=LOGS  # gives 12

curl http://localhost:8000/api/v2/surge_alert/?country__iso3__in=HND,HUN\&molnix_tags=2,3  # gives 14
curl http://localhost:8000/api/v2/surge_alert/?country__iso3__in=HND,HUN\&molnix_tag_names=LOGS,COM,LOG-CO  # gives 27

Also in docs:
kép

Deployed to Staging.
Many thanks to @thenav56 for the great cleanup!

@JonathanGarro, would you mind to check, if this works as you expected?

thanks @tovari - i just tested a few and it seems to work great! huge thanks to the team, this will be extremely useful! i appreciate y'all.