Skip to content
Open
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
23 changes: 14 additions & 9 deletions app/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,25 @@
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
from ..services.location.nyt import NYTLocationService
from app.data.dataSource import DataSource

# Mapping of services to data-sources.
DATA_SOURCES = {
"jhu": JhuLocationService(),
"csbs": CSBSLocationService(),
"nyt": NYTLocationService(),
}

DATA_SOURCES = ["jhu","csbs","nyt"]

def data_source(source):
"""
Retrieves the provided data-source service.

:returns: The service.
:rtype: LocationService
"""
return DATA_SOURCES.get(source.lower())
"""

exists = False

for i in DATA_SOURCES:
if DATA_SOURCES.index[i] == source:
exists = True

if exists == True:
return DataSource.getService(source)
else:
return DataSource.getService("jhu")
15 changes: 15 additions & 0 deletions app/data/dataSource.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from ..services.location.csbs import CSBSLocationService
from ..services.location.jhu import JhuLocationService
from ..services.location.nyt import NYTLocationService

class DataSource():
def getService(source):
if source.lower() == "csbs":
temp = CSBSLocationService()
return temp
elif source.lower() == "nyt":
temp = NYTLocationService()
return temp
else:
temp = JhuLocationService()
return temp
2 changes: 1 addition & 1 deletion app/routers/v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ async def sources():
"""
Retrieves a list of data-sources that are availble to use.
"""
return {"sources": list(DATA_SOURCES.keys())}
return {"sources": DATA_SOURCES}