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
7 changes: 5 additions & 2 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""app.location"""
from ..coordinates import Coordinates
from ..utils import countries
from ..utils.countries import CountryCodeProvider
from ..utils.populations import country_population


Expand All @@ -27,6 +27,9 @@ def __init__(
self.deaths = deaths
self.recovered = recovered

#country data
self.country_code_provider = CountryCodeProvider()

@property
def country_code(self):
"""
Expand All @@ -35,7 +38,7 @@ def country_code(self):
:returns: The country code.
:rtype: str
"""
return (countries.country_code(self.country) or countries.DEFAULT_COUNTRY_CODE).upper()
return (self.country_code_provider.country_code(self.country) or self.country_code_provider.DEFAULT_COUNTRY_CODE).upper()

@property
def country_population(self):
Expand Down
6 changes: 3 additions & 3 deletions app/services/location/jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
from ...coordinates import Coordinates
from ...location import TimelinedLocation
from ...models import Timeline
from ...utils import countries
from ...utils.countries import CountryCodeProvider
from ...utils import date as date_util
from ...utils import httputils
from . import LocationService

LOGGER = logging.getLogger("services.location.jhu")
PID = os.getpid()

country_code_provider = CountryCodeProvider()

class JhuLocationService(LocationService):
"""
Expand Down Expand Up @@ -98,7 +98,7 @@ async def get_category(category):
{
# General info.
"country": country,
"country_code": countries.country_code(country),
"country_code": country_code_provider.country_code(country),
"province": item["Province/State"],
# Coordinates.
"coordinates": {"lat": item["Lat"], "long": item["Long"],},
Expand Down
Loading