Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from scout_apm.async_.starlette import ScoutMiddleware
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware

from .config import get_settings
from .data import data_source
from .routers import V1, V2
from .utils.httputils import setup_client_session, teardown_client_session
from app.config import get_settings
from app.data import data_source
from app.routers import V1, V2
from app.utils.httputils import setup_client_session, teardown_client_session

# ############
# FastAPI App
Expand Down
24 changes: 8 additions & 16 deletions app/services/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,15 @@ class LocationService(ABC):
"""
Service for retrieving locations.
"""

@abstractmethod
async def get_all(self):
"""
Gets and returns all of the locations.
# Get the locations.
locations = await get_locations()
return locations

async def get(self, loc_id): # pylint: disable=arguments-differ
# Get location at the index equal to provided id.
locations = await self.get_all()
return locations[loc_id]

:returns: The locations.
:rtype: List[Location]
"""
raise NotImplementedError

@abstractmethod
async def get(self, id): # pylint: disable=redefined-builtin,invalid-name
"""
Gets and returns location with the provided id.

:returns: The location.
:rtype: Location
"""
raise NotImplementedError
4 changes: 2 additions & 2 deletions app/services/location/csbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class CSBSLocationService(LocationService):
"""
Service for retrieving locations from csbs
"""

'''
async def get_all(self):
# Get the locations.
locations = await get_locations()
Expand All @@ -29,7 +29,7 @@ async def get(self, loc_id): # pylint: disable=arguments-differ
# Get location at the index equal to the provided id.
locations = await self.get_all()
return locations[loc_id]

'''

# Base URL for fetching data
BASE_URL = "https://facts.csbs.org/covid-19/covid19_county.csv"
Expand Down
4 changes: 2 additions & 2 deletions app/services/location/jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JhuLocationService(LocationService):
"""
Service for retrieving locations from Johns Hopkins CSSE (https://github.com/CSSEGISandData/COVID-19).
"""

'''
async def get_all(self):
# Get the locations.
locations = await get_locations()
Expand All @@ -35,7 +35,7 @@ async def get(self, loc_id): # pylint: disable=arguments-differ
# Get location at the index equal to provided id.
locations = await self.get_all()
return locations[loc_id]

'''

# ---------------------------------------------------------------

Expand Down
4 changes: 2 additions & 2 deletions app/services/location/nyt.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class NYTLocationService(LocationService):
"""
Service for retrieving locations from New York Times (https://github.com/nytimes/covid-19-data).
"""

'''
async def get_all(self):
# Get the locations.
locations = await get_locations()
Expand All @@ -30,7 +30,7 @@ async def get(self, loc_id): # pylint: disable=arguments-differ
# Get location at the index equal to provided id.
locations = await self.get_all()
return locations[loc_id]

'''

# ---------------------------------------------------------------

Expand Down