Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ docs/_build/
target/

# OSX Stuff
.DS_Store
.DS_Store

# IntelliJ/Pycharm
.idea/
9 changes: 9 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,28 @@ url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]
async-asgi-testclient = "*"
async_generator = "*"
asyncmock = "*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These back-ports should be adjusted so that they are only installed when required.
https://pipenv.readthedocs.io/en/latest/basics/#specifying-versions-of-a-package
https://pipenv.readthedocs.io/en/latest/advanced/#specifying-basically-anything

I'll try to do this tonight if I have a chance.
Thanks for all the notes, should make this easy.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, happy to help!

bandit = "*"
black = "==19.10b0"
coveralls = "*"
importlib-metadata = {version="*", markers="python_version<'3.8'"}
invoke = "*"
isort = "*"
pylint = "*"
pytest = "*"
pytest-asyncio = "*"
pytest-cov = "*"

[packages]
aiohttp = "*"
asyncache = "*"
cachetools = "*"
dataclasses = {version="*", markers="python_version<'3.7'"}
fastapi = "*"
gunicorn = "*"
idna_ssl = {version="*", markers="python_version<'3.7'"}
python-dateutil = "*"
python-dotenv = "*"
requests = "*"
Expand Down
184 changes: 180 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .data import data_source
from .router.v1 import V1
from .router.v2 import V2
from .utils.httputils import setup_client_session, teardown_client_session

# ############
# FastAPI App
Expand All @@ -28,6 +29,8 @@
version="2.0.1",
docs_url="/",
redoc_url="/docs",
on_startup=[setup_client_session],
on_shutdown=[teardown_client_session],
)

# #####################
Expand Down
8 changes: 4 additions & 4 deletions app/router/v1/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@


@V1.get("/all")
def all(): # pylint: disable=redefined-builtin
async def all(): # pylint: disable=redefined-builtin
"""Get all the categories."""
confirmed = get_category("confirmed")
deaths = get_category("deaths")
recovered = get_category("recovered")
confirmed = await get_category("confirmed")
deaths = await get_category("deaths")
recovered = await get_category("recovered")

return {
# Data.
Expand Down
6 changes: 4 additions & 2 deletions app/router/v1/confirmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


@V1.get("/confirmed")
def confirmed():
async def confirmed():
"""Confirmed cases."""
return get_category("confirmed")
confirmed_data = await get_category("confirmed")

return confirmed_data
6 changes: 4 additions & 2 deletions app/router/v1/deaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


@V1.get("/deaths")
def deaths():
async def deaths():
"""Total deaths."""
return get_category("deaths")
deaths_data = await get_category("deaths")

return deaths_data
6 changes: 4 additions & 2 deletions app/router/v1/recovered.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@


@V1.get("/recovered")
def recovered():
async def recovered():
"""Recovered cases."""
return get_category("recovered")
recovered_data = await get_category("recovered")

return recovered_data
4 changes: 2 additions & 2 deletions app/router/v2/latest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@


@V2.get("/latest", response_model=Latest)
def get_latest(request: Request, source: Sources = "jhu"): # pylint: disable=unused-argument
async def get_latest(request: Request, source: Sources = "jhu"): # pylint: disable=unused-argument
"""
Getting latest amount of total confirmed cases, deaths, and recoveries.
"""
locations = request.state.source.get_all()
locations = await request.state.source.get_all()
return {
"latest": {
"confirmed": sum(map(lambda location: location.confirmed, locations)),
Expand Down
Loading