IFRCGo / go-web-app

GO Web application! GO is a Red Cross Red Crescent platform to connect information on emergency needs with the right response.
https://go.ifrc.org
MIT License
5 stars 0 forks source link

Surge Alerts: use `molnix_status` for filtering and display #1200

Open batpad opened 1 week ago

batpad commented 1 week ago

When we fetch Surge Alerts from the Molnix API, they come with a status string from Molnix, which we store as molnix_status.

For various historical reasons, we don't use this field to denote "Open" and "Closed" positions on the Surge Alerts table:

Screenshot 2024-06-21 at 2 35 43 PM

We use a different status field on the Surge Alert model, which is filled in based on the closes timestamp returned from Molnix - logic here: https://github.com/IFRCGo/go-api/blob/develop/notifications/models.py#L81

We should deprecate the status field and remove logic on our end to calculate it. Anyways, it seems very brittle to be doing that calculation on save.

Speaking to @anamariaescobar we should remove all custom logic that tries to infer the status of an Alert, and just use whatever Molnix gives us as molnix_status, regardless of whether this causes a mismatch with the dates of the alert, which can be treated as an upstream data problem.

There are three possible values of molnix_status, and they should map to the following strings for display / filtering:

In places in the frontend where we want to only show "Open" positions, we are currently filtering by the end_date: https://github.com/IFRCGo/go-web-app/blob/develop/app/src/views/SurgeOverview/SurgeAlertsTable/index.tsx#L87 - instead, we should just filter my molnix_status and show only things that are Open or Stood Down.

Am sorry this has gotten a bit confusing due to the way this has evolved a bit and assumptions we made that have changed. I do think the above changes will greatly simplify everything once we implement them, as the idea would be to remove all custom logic on our end and just used the molnix_status field to determine Open, Closed and Stood Down.

cc @anamariaescobar @frozenhelium @szabozoltan69 @thenav56 @tovari