AlexLipp / thames-sewage

Realtime mapping of sewage release events in Thames basin
GNU General Public License v3.0
11 stars 0 forks source link

Make update function compatible with new robust PooPy history functions #19

Closed AlexLipp closed 9 months ago

AlexLipp commented 9 months ago

In a recent PR for PooPy, the functions that generate the discharge history for a monitor based on the Thames Water API was updated. The method is more robust and prevents the system breaking if an erroneous empty response is returned.

This PR updates the update.py script to better incorporate these changes and moire elegant respond if this problem is encountered. In PooPy if an empty response is received, an exception is raised and the script aborts. Ideally, if this is the case, there is no history at all displayed on SewageMap as the data cannot be trusted. To implement this behaviour, I now always delete the data present in the AWS bucket before generating a new history. If the exception is raised, then there is no history present in the API. If it is not raised, then the history is updated. There is however, a brief (~1 minute) downtime when the history is updating when it won't be visible.