Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
nat236919 committed Mar 18, 2021
2 parents 0f6479c + 8da6171 commit e9df64f
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 120 deletions.
16 changes: 13 additions & 3 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@
"login": "nat236919",
"name": "Nuttaphat Arunoprayoch",
"avatar_url": "https://avatars0.githubusercontent.com/u/9074112?v=4",
"profile": "http://nuttaphat.azurewebsites.net",
"profile": "https://nuttaphat.com",
"contributions": [
"maintenance",
"code",
"bug",
"doc",
"ideas",
"review"
]
},
Expand Down Expand Up @@ -61,7 +60,18 @@
"avatar_url": "https://avatars.githubusercontent.com/u/43126781?v=4",
"profile": "https://github.com/owen-duncan-snobel",
"contributions": [
"doc"
"code",
"doc",
"financial"
]
},
{
"login": "mSitkovets",
"name": "Maria Sitkovets",
"avatar_url": "https://avatars.githubusercontent.com/u/28634142?v=4",
"profile": "https://www.linkedin.com/in/maria-sitkovets-03994b159/",
"contributions": [
"code"
]
}
],
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</p>

<p align="center">
<a href="https://github.com/nat236919/Covid2019API/issues" target="_blank">
<img src="https://img.shields.io/github/issues/nat236919/Covid2019API" alt="issues">
<a href="https://github.com/nat236919/covid19-api/issues" target="_blank">
<img src="https://img.shields.io/github/issues/nat236919/covid19-api" alt="issues">
</a>
<a href="https://github.com/nat236919/Covid2019API/forks" target="_blank">
<img src="https://img.shields.io/github/forks/nat236919/Covid2019API" alt="forks">
<a href="https://github.com/nat236919/covid19-api/network/members" target="_blank">
<img src="https://img.shields.io/github/forks/nat236919/covid19-api" alt="forks">
</a>
<a href="https://github.com/nat236919/Covid2019API/stars" target="_blank">
<img src="https://img.shields.io/github/stars/nat236919/Covid2019API" alt="starts">
<a href="https://github.com/nat236919/covid19-api/stargazers" target="_blank">
<img src="https://img.shields.io/github/stars/nat236919/covid19-api" alt="starts">
</a>
<a href="https://github.com/nat236919/Covid2019API/blob/master/LICENCE" target="_blank">
<img src="https://img.shields.io/github/license/nat236919/Covid2019API" alt="licence">
<a href="https://github.com/nat236919/covid19-api/blob/master/LICENCE" target="_blank">
<img src="https://img.shields.io/github/license/nat236919/covid19-api" alt="licence">
</a>
<a href="https://travis-ci.org/github/nat236919/covid19-api" target="_blank">
<img src="https://travis-ci.org/nat236919/covid19-api.svg?branch=development" alt="build">
Expand All @@ -30,7 +30,7 @@ This API provides the information regarding '2019 Novel Coronavirus (covid-19)'.

## Example

* https://covid19.nuttaphat.com/
* https://covid19api.azurewebsites.net/
* https://covid2019-api.herokuapp.com/

## Applications
Expand All @@ -41,9 +41,9 @@ This API provides the information regarding '2019 Novel Coronavirus (covid-19)'.
* [BAILAM (Data and API Integration)](https://www.bailam.com/covid19)
* [Coronavirus Tech Handbook (Data Tools)](https://coronavirustechhandbook.com/data-tools)

### References
### Reference

https://github.com/CSSEGISandData/COVID-19
* https://github.com/CSSEGISandData/COVID-19

## Branches

Expand Down Expand Up @@ -128,12 +128,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://nuttaphat.com/"><img src="https://avatars0.githubusercontent.com/u/9074112?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nuttaphat Arunoprayoch</b></sub></a><br /><a href="#maintenance-nat236919" title="Maintenance">🚧</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/issues?q=author%3Anat236919" title="Bug reports">🐛</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Documentation">📖</a> <a href="https://github.com/nat236919/covid19-api/pulls?q=is%3Apr+reviewed-by%3Anat236919" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://nuttaphat.com"><img src="https://avatars0.githubusercontent.com/u/9074112?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nuttaphat Arunoprayoch</b></sub></a><br /><a href="#maintenance-nat236919" title="Maintenance">🚧</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/issues?q=author%3Anat236919" title="Bug reports">🐛</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Documentation">📖</a> <a href="https://github.com/nat236919/covid19-api/pulls?q=is%3Apr+reviewed-by%3Anat236919" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/soapy1"><img src="https://avatars0.githubusercontent.com/u/976973?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sophia Castellarin</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=soapy1" title="Code">💻</a></td>
<td align="center"><a href="https://keybase.io/endoffile78"><img src="https://avatars2.githubusercontent.com/u/11342054?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeremy</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=endoffile78" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ChooseYourPlan"><img src="https://avatars2.githubusercontent.com/u/32968964?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim</b></sub></a><br /><a href="#translation-ChooseYourPlan" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/melsaa"><img src="https://avatars0.githubusercontent.com/u/32761948?v=4?s=100" width="100px;" alt=""/><br /><sub><b>melsaa</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=melsaa" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/owen-duncan-snobel"><img src="https://avatars.githubusercontent.com/u/43126781?v=4?s=100" width="100px;" alt=""/><br /><sub><b>owen-duncan-snobel</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/issues?q=author%3Aowen-duncan-snobel" title="Bug reports">🐛</a> <a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/owen-duncan-snobel"><img src="https://avatars.githubusercontent.com/u/43126781?v=4?s=100" width="100px;" alt=""/><br /><sub><b>owen-duncan-snobel</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Documentation">📖</a> <a href="#financial-owen-duncan-snobel" title="Financial">💵</a></td>
<td align="center"><a href="https://www.linkedin.com/in/maria-sitkovets-03994b159/"><img src="https://avatars.githubusercontent.com/u/28634142?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maria Sitkovets</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=mSitkovets" title="Code">💻</a></td>
</tr>
</table>

Expand Down
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
'app': {
'title': 'COVID-19 API',
'description': 'Simply FAST API for COVID-19 cases exploration',
'version': '2.1.1'
'version': '2.1.2'
}
}
27 changes: 14 additions & 13 deletions app/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
</p>

<p align="center">
<a href="https://github.com/nat236919/Covid2019API/issues" target="_blank">
<img src="https://img.shields.io/github/issues/nat236919/Covid2019API" alt="issues">
<a href="https://github.com/nat236919/covid19-api/issues" target="_blank">
<img src="https://img.shields.io/github/issues/nat236919/covid19-api" alt="issues">
</a>
<a href="https://github.com/nat236919/Covid2019API/forks" target="_blank">
<img src="https://img.shields.io/github/forks/nat236919/Covid2019API" alt="forks">
<a href="https://github.com/nat236919/covid19-api/network/members" target="_blank">
<img src="https://img.shields.io/github/forks/nat236919/covid19-api" alt="forks">
</a>
<a href="https://github.com/nat236919/Covid2019API/stars" target="_blank">
<img src="https://img.shields.io/github/stars/nat236919/Covid2019API" alt="starts">
<a href="https://github.com/nat236919/covid19-api/stargazers" target="_blank">
<img src="https://img.shields.io/github/stars/nat236919/covid19-api" alt="starts">
</a>
<a href="https://github.com/nat236919/Covid2019API/blob/master/LICENCE" target="_blank">
<img src="https://img.shields.io/github/license/nat236919/Covid2019API" alt="licence">
<a href="https://github.com/nat236919/covid19-api/blob/master/LICENCE" target="_blank">
<img src="https://img.shields.io/github/license/nat236919/covid19-api" alt="licence">
</a>
<a href="https://travis-ci.org/github/nat236919/covid19-api" target="_blank">
<img src="https://travis-ci.org/nat236919/covid19-api.svg?branch=development" alt="build">
Expand All @@ -30,7 +30,7 @@ This API provides the information regarding '2019 Novel Coronavirus (covid-19)'.

## Example

* https://covid19.nuttaphat.com/
* https://covid19api.azurewebsites.net/
* https://covid2019-api.herokuapp.com/

## Applications
Expand All @@ -41,9 +41,9 @@ This API provides the information regarding '2019 Novel Coronavirus (covid-19)'.
* [BAILAM (Data and API Integration)](https://www.bailam.com/covid19)
* [Coronavirus Tech Handbook (Data Tools)](https://coronavirustechhandbook.com/data-tools)

### References
### Reference

https://github.com/CSSEGISandData/COVID-19
* https://github.com/CSSEGISandData/COVID-19

## Branches

Expand Down Expand Up @@ -128,12 +128,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="https://nuttaphat.com/"><img src="https://avatars0.githubusercontent.com/u/9074112?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nuttaphat Arunoprayoch</b></sub></a><br /><a href="#maintenance-nat236919" title="Maintenance">🚧</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/issues?q=author%3Anat236919" title="Bug reports">🐛</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Documentation">📖</a> <a href="https://github.com/nat236919/covid19-api/pulls?q=is%3Apr+reviewed-by%3Anat236919" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://nuttaphat.com"><img src="https://avatars0.githubusercontent.com/u/9074112?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nuttaphat Arunoprayoch</b></sub></a><br /><a href="#maintenance-nat236919" title="Maintenance">🚧</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/issues?q=author%3Anat236919" title="Bug reports">🐛</a> <a href="https://github.com/nat236919/covid19-api/commits?author=nat236919" title="Documentation">📖</a> <a href="https://github.com/nat236919/covid19-api/pulls?q=is%3Apr+reviewed-by%3Anat236919" title="Reviewed Pull Requests">👀</a></td>
<td align="center"><a href="https://github.com/soapy1"><img src="https://avatars0.githubusercontent.com/u/976973?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sophia Castellarin</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=soapy1" title="Code">💻</a></td>
<td align="center"><a href="https://keybase.io/endoffile78"><img src="https://avatars2.githubusercontent.com/u/11342054?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeremy</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=endoffile78" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ChooseYourPlan"><img src="https://avatars2.githubusercontent.com/u/32968964?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tim</b></sub></a><br /><a href="#translation-ChooseYourPlan" title="Translation">🌍</a></td>
<td align="center"><a href="https://github.com/melsaa"><img src="https://avatars0.githubusercontent.com/u/32761948?v=4?s=100" width="100px;" alt=""/><br /><sub><b>melsaa</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=melsaa" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/owen-duncan-snobel"><img src="https://avatars.githubusercontent.com/u/43126781?v=4?s=100" width="100px;" alt=""/><br /><sub><b>owen-duncan-snobel</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/issues?q=author%3Aowen-duncan-snobel" title="Bug reports">🐛</a> <a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Documentation">📖</a></td>
<td align="center"><a href="https://github.com/owen-duncan-snobel"><img src="https://avatars.githubusercontent.com/u/43126781?v=4?s=100" width="100px;" alt=""/><br /><sub><b>owen-duncan-snobel</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Code">💻</a> <a href="https://github.com/nat236919/covid19-api/commits?author=owen-duncan-snobel" title="Documentation">📖</a> <a href="#financial-owen-duncan-snobel" title="Financial">💵</a></td>
<td align="center"><a href="https://www.linkedin.com/in/maria-sitkovets-03994b159/"><img src="https://avatars.githubusercontent.com/u/28634142?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maria Sitkovets</b></sub></a><br /><a href="https://github.com/nat236919/covid19-api/commits?author=mSitkovets" title="Code">💻</a></td>
</tr>
</table>

Expand Down
34 changes: 18 additions & 16 deletions app/integrators/covid_api_v2_integrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@
TimeseriesUSDataModel,
TimeseriesUSInfoModel,
TimeseriesUSModel, TotalModel)
from utils.get_data import (get_data_daily_reports,
get_data_daily_reports_us, get_data_lookup_table,
get_data_time_series, get_US_time_series)
from utils.get_data import (DailyReports, DataTimeSeries,
get_data_lookup_table)


class CovidAPIv2Integrator:
Expand All @@ -37,15 +36,18 @@ class CovidAPIv2Integrator:
"ts": int = "{timestamp}
}
"""
def __init__(self) -> None:
""" Initiate DataFrames """

def __init__(self, daily_reports: DailyReports, time_series: DataTimeSeries) -> None:
""" Initiate instances """
self.lookup_table = get_data_lookup_table()
self.scheme = {
'data': None,
'dt': None,
'ts': None
}

self.daily_reports = daily_reports
self.time_series = time_series

def wrap_data(func) -> ResponseModel:
""" Wrap a result in a schemed data """
@wraps(func)
Expand All @@ -71,7 +73,7 @@ def wrapper(self, *args, **kwargs):
def get_current(self) -> List[CurrentModel]:
""" Current data from all locations (Lastest date) """
concerned_columns = ['Confirmed', 'Deaths', 'Recovered', 'Active']
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
self.df_grp_by_country = self.df.groupby('Country_Region')[concerned_columns].sum()
self.df_grp_by_country[concerned_columns] = self.df_grp_by_country[concerned_columns].astype(int)

Expand All @@ -89,7 +91,7 @@ def get_current(self) -> List[CurrentModel]:
@wrap_data
def get_current_US(self) -> List[CurrentUSModel]:
""" Get current data for USA's situation """
self.df_US = get_data_daily_reports_us() # Get base data
self.df_US = self.daily_reports.get_data_daily_reports(US=True) # Get base data

concerned_columns = ['Confirmed', 'Deaths', 'Recovered', 'Active']
df = self.df_US.groupby(['Province_State'])[concerned_columns].sum().sort_values(by='Confirmed', ascending=False)
Expand All @@ -108,7 +110,7 @@ def get_current_US(self) -> List[CurrentUSModel]:
def get_country(self, country_name: str) -> CountryModel:
""" Get a country data from its name or ISO 2 """
concerned_columns = ['Confirmed', 'Deaths', 'Recovered', 'Active']
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
self.df_grp_by_country = self.df.groupby('Country_Region')[concerned_columns].sum()
self.df_grp_by_country[concerned_columns] = self.df_grp_by_country[concerned_columns].astype(int)

Expand Down Expand Up @@ -138,7 +140,7 @@ def get_country(self, country_name: str) -> CountryModel:
@wrap_data
def get_confirmed(self) -> ConfirmedModel:
""" Summation of all confirmed cases """
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
data = ConfirmedModel(
confirmed=int(self.df['Confirmed'].sum())
)
Expand All @@ -150,7 +152,7 @@ def get_confirmed(self) -> ConfirmedModel:
@wrap_data
def get_deaths(self) -> DeathsModel:
""" Summation of all deaths """
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
data = DeathsModel(
deaths=int(self.df['Deaths'].sum())
)
Expand All @@ -162,7 +164,7 @@ def get_deaths(self) -> DeathsModel:
@wrap_data
def get_recovered(self) -> RecoveredModel:
""" Summation of all recovers """
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
data = RecoveredModel(
recovered=int(self.df['Recovered'].sum())
)
Expand All @@ -174,7 +176,7 @@ def get_recovered(self) -> RecoveredModel:
@wrap_data
def get_active(self) -> ActiveModel:
""" Summation of all actives """
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
data = ActiveModel(
active=int(self.df['Active'].sum())
)
Expand All @@ -186,7 +188,7 @@ def get_active(self) -> ActiveModel:
@wrap_data
def get_total(self) -> TotalModel:
""" Summation of Confirmed, Deaths, Recovered, Active """
self.df = get_data_daily_reports() # Get base data
self.df = self.daily_reports.get_data_daily_reports() # Get base data
data = TotalModel(
confirmed=int(self.df['Confirmed'].sum()),
deaths=int(self.df['Deaths'].sum()),
Expand All @@ -204,7 +206,7 @@ def get_time_series(self, case: str) -> List[Any]:
1.) global
2.) confirmed, deaths, recovered
"""
self.df_time_series = get_data_time_series() # Get base data
self.df_time_series = self.time_series.get_data_time_series() # Get base data

if case not in ['global']:
raw_data = self.df_time_series[case].T.to_dict()
Expand Down Expand Up @@ -272,7 +274,7 @@ def get_US_time_series(self, case: str) -> List[TimeseriesUSModel]:
if case not in ['confirmed', 'deaths']:
data = []
else:
self.df_US_time_series = get_US_time_series() # Get base data
self.df_US_time_series = self.time_series.get_data_time_series(US=True) # Get base data
raw_data = self.df_US_time_series[case].T.to_dict()
data = self.__extract_US_time_series(raw_data)

Expand Down
5 changes: 4 additions & 1 deletion app/routers/v2/router_api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
from starlette.requests import Request

from . import v2
from utils.get_data import DailyReports, DataTimeSeries

# Initiate Integrator
COVID_API_V2 = CovidAPIv2Integrator()
DAILY_REPORTS = DailyReports()
DATA_TIME_SERIES = DataTimeSeries()
COVID_API_V2 = CovidAPIv2Integrator(DAILY_REPORTS, DATA_TIME_SERIES)


# Logging
Expand Down
Loading

0 comments on commit e9df64f

Please sign in to comment.