diff --git a/app/services/location/jhu.py b/app/services/location/jhu.py index ebed3960..6b47efb6 100644 --- a/app/services/location/jhu.py +++ b/app/services/location/jhu.py @@ -16,6 +16,7 @@ from ...utils import date as date_util from ...utils import httputils from . import LocationService +from ...utils.baseurls import BaseUrl LOGGER = logging.getLogger("services.location.jhu") PID = os.getpid() @@ -41,7 +42,7 @@ async def get(self, loc_id): # pylint: disable=arguments-differ # Base URL for fetching category. -BASE_URL = "https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/" +BASE_URL = BaseUrl.JHU @cached(cache=TTLCache(maxsize=4, ttl=1800)) @@ -226,3 +227,4 @@ def parse_history(key: tuple, locations: list, index: int): LOGGER.debug(f"iteration data merge error: {index} {key}") return location_history + diff --git a/app/utils/baseurls.py b/app/utils/baseurls.py new file mode 100644 index 00000000..ccebf743 --- /dev/null +++ b/app/utils/baseurls.py @@ -0,0 +1,10 @@ +import enum + +class BaseUrl(str, enum.Enum): + """ + A base url available for retrieving data. + """ + + JHU = "https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/" + CSBS = "https://facts.csbs.org/covid-19/covid19_county.csv" + NYT = "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv"