covid-19-api icon indicating copy to clipboard operation
covid-19-api copied to clipboard

Daily Overview of Country

Open johanneshaberlah opened this issue 5 years ago • 4 comments

Would it be possible to display the daily statistics also sorted by country. My suggestion would be /countries/[country]/daily/[date] This would be extremely handy for detail pages that only need the data from one country and would save a lot of overhead and be sorted in such a use case. Thanks a lot.

johanneshaberlah avatar Mar 28 '20 13:03 johanneshaberlah

My current approach for that is as follow:

for (let i = daysToFetch; i > 0; i -= 1) {
        const data = await fetch(`${API_URL}/daily/${lightFormat(subDays(new Date(), i), 'MM-dd-yyyy')}`).then(data => data.json());
      }

Not ideal, as it is not handled by the API, but it works.

vitorpdasilva avatar Mar 30 '20 04:03 vitorpdasilva

My current approach for that is as follow:

for (let i = daysToFetch; i > 0; i -= 1) {
        const data = await fetch(`${API_URL}/daily/${lightFormat(subDays(new Date(), i), 'MM-dd-yyyy')}`).then(data => data.json());
      }

Not ideal, as it is not handled by the API, but it works.

@vitorboccio - Can you elaborate more on how you solved the workaround

jephjohnson avatar Aug 10 '20 01:08 jephjohnson

@jephjohnson essentially the workaround is looping through the dates in a backwards way and pushing the result to an array. so in this loop above what it is doing is today today -1 today -2 today -3 etc. As I mentioned, its not ideal, thanks a while to load all the data, but it works. Ideally we should get those results from an API level, but thats what we have for now.

vitorpdasilva avatar Aug 25 '20 00:08 vitorpdasilva

Yes, that's how I solved the issue. But I still think, that many other people dealing with this issue would be thankful, if there would be a feature solving this in the actual API.

johanneshaberlah avatar Aug 25 '20 11:08 johanneshaberlah