Adds /landslide endpoint to API for use by the Kuti Landslide Risk Dashboard - #732
Conversation
…p, but will fail on trying to access database in /landslide endpoint.
…p, but will fail on trying to access database in /landslide endpoint.
cstephen
left a comment
There was a problem hiding this comment.
This looks good, generally! I kicked the tires on this a bit, tried both the Craig and Kasaan URLs and made sure they returned data. I also looked through the code diff to make sure it made sense. Some of the code related to community filtering has changed in this PR, so I made sure community filtering is still working as expected for other webapps (Arctic-EDS, Alaska Wildfire Explorer, Northern Climate Reports).
The only issues I noticed are that two of the pytest tests failed:
$ pytest tests/test_landslide.py
...
====================================================== short test summary info ======================================================
FAILED tests/test_landslide.py::test_landslide_ak91 - AssertionError: Missing required key: block_24hr
FAILED tests/test_landslide.py::test_landslide_ak182 - AssertionError: Missing required key: block_24hr
============================================== 2 failed, 6 passed, 7 warnings in 1.22s ==============================================
Looks like there is indeed no block_24hr in the data response, so I'm thinking maybe the two failed pytest tests are outdated?
The only thing I noticed is that the structure of expected data response shown in the API documentation doesn't match the actual API response. I'm thinking the documentation is just outdated?
Otherwise, this is looking great!
cstephen
left a comment
There was a problem hiding this comment.
False alarm! I was running the branch off a very old commit (from March) during my previous review. After pulling the latest commit, all pytests are working and the documentation matches the data response. Everything looks good!!
This PR adds the /landslide endpoint to the API for use by the Kuti Landslide Risk Dashboard. It queries the database holding the 12 hour forecast and returns the data in an ordered JSON. I have added documentation related to the landslide endpoint along with tests to highlight what happens when we get into various states of database or API unhappiness.
To run the /landslide route, you must enter the following environment variables:
DB_NAME, DB_HOST, DB_USER, DB_PASSWORD
All of those environment variables can be found in our Keeper under Landslide Database Read-Only User
For testing, there are only two places you can test currently, which matches the dashboard, Craig and Kasaan. To access them go to:
Craig
http://localhost:5000/landslide/AK91
Kasaan
http://localhost:5000/landslide/AK182
Let me know if you have any questions!