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 new surge alert filters to API #1975

Closed
JonathanGarro opened this issue Dec 8, 2023 · 13 comments
Closed

Add new surge alert filters to API #1975

JonathanGarro opened this issue Dec 8, 2023 · 13 comments
Labels

Comments

@JonathanGarro
Copy link

JonathanGarro commented Dec 8, 2023

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.
@szabozoltan69
Copy link
Contributor

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.)

@JonathanGarro
Copy link
Author

@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.

@szabozoltan69
Copy link
Contributor

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

@szabozoltan69
Copy link
Contributor

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

@JonathanGarro
Copy link
Author

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

@szabozoltan69
Copy link
Contributor

I do it also, ok. :-)

@batpad batpad changed the title Add new surge alert fields to API Add new surge alert filters to API Dec 11, 2023
@batpad
Copy link
Collaborator

batpad commented Dec 11, 2023

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.

@szabozoltan69
Copy link
Contributor

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

@szabozoltan69
Copy link
Contributor

Also in docs:
kép

@szabozoltan69
Copy link
Contributor

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

@tovari
Copy link

tovari commented Jan 24, 2024

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

@JonathanGarro
Copy link
Author

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.

@tovari tovari closed this as completed Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants