HS-Datadesk / koronavirus-avoindata

HS julkaisee Suomen koronavirustartunnat avoimena datana.
https://www.hs.fi/aihe/koronavirus/
MIT License
100 stars 27 forks source link

API seems to be down #67

Closed valstu closed 4 years ago

valstu commented 4 years ago

https://w3qa5ydb4l.execute-api.eu-west-1.amazonaws.com/prod/finnishCoronaData/v2 api in this address is giving Internal server error

quarian commented 4 years ago

So it seems - THL updated some historical data, causing the compatibility code to throw a fit. I'll fix it ASAP.

quarian commented 4 years ago

@valstu @petetnt it's up now.

For those curious, the issue was as follows:

When I made the v2 API on top of new data sources, I decided to maintain full compatibility to v1. This required some handywork, since the new source of death data is the THL daily report which gives the cumulative amount of deaths each day per special health care (as compared to our old data source, which would simply have the data as it was reported, so one row in a database per observation, whereas the new model has the amount of items for each day on a row).

What this means that I had to expand the observations in the new API for the compatible API for each day they were reported for. I would calculate how many items I would have to expand for each day based on the difference of reported deaths on consecutive days.

The problem arose when THL corrected their data, causing one day to have less deaths than a previous day (which should never happen when you are reporting cumulative deaths, or so I assumed). This caused the difference between the consecutive days to be negative, which caused my expansion code to brick. The fix for now is that I have capped the maximum amount of deaths per day to the latest reported - this should maintain the correct total number of deaths and prevent issues like this in the future.

If this is satisfactory, close the issue.

petetnt commented 4 years ago

Seems to work, thanks!

valstu commented 4 years ago

Thanks for your explanation, seems to work again. In the end I would classify this as a happy bug, always glad to hear when any of numbers related to Covid-19 and smaller than reported. Closing issue.