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
36 changes: 0 additions & 36 deletions CONTRIBUTING.md

This file was deleted.

21 changes: 0 additions & 21 deletions app/data/__init__.py

This file was deleted.

14 changes: 9 additions & 5 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""app.location"""
from ..coordinates import Coordinates
from ..utils import countries
from ..utils.countries import Country
# from ..utils import country
from ..utils.populations import country_population


Expand All @@ -10,12 +11,13 @@ class Location: # pylint: disable=too-many-instance-attributes
A location in the world affected by the coronavirus.
"""

def __init__(
def __init__(
self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered,
): # pylint: disable=too-many-arguments
# General info.
self.id = id
self.country = country.strip()
self.country_obj = country # country_obj should contain a reference to a Country Class that is being passed
self.country = self.country_obj.get_country().strip()
self.province = province.strip()
self.coordinates = coordinates

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


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

@property
def country_population(self):
Expand Down Expand Up @@ -91,7 +95,7 @@ def __init__(self, id, country, province, coordinates, last_updated, timelines):
# Statistics (retrieve latest from timelines).
confirmed=timelines.get("confirmed").latest or 0,
deaths=timelines.get("deaths").latest or 0,
recovered=timelines.get("recovered").latest or 0,
recovered=timelines.get("recovered").latest or 0
)

# Set timelines.
Expand Down
121 changes: 0 additions & 121 deletions app/main.py

This file was deleted.

9 changes: 6 additions & 3 deletions app/services/location/jhu.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
from ...coordinates import Coordinates
from ...location import TimelinedLocation
from ...models import Timeline
from ...utils import countries
from ...utils.countries import Country
from ...utils import date as date_util
from ...utils import httputils
from . import LocationService


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

Expand Down Expand Up @@ -94,11 +95,12 @@ async def get_category(category):
latest = list(history.values())[-1]

# Normalize the item and append to locations.

locations.append(
{
# General info.
"country": country,
"country_code": countries.country_code(country),
"country_code": Country(country),
"province": item["Province/State"],
# Coordinates.
"coordinates": {"lat": item["Lat"], "long": item["Long"],},
Expand Down Expand Up @@ -169,13 +171,14 @@ async def get_locations():

# Grab coordinates.
coordinates = location["coordinates"]
# Creation of Country Class

# Create location (supporting timelines) and append.
locations.append(
TimelinedLocation(
# General info.
index,
location["country"],
Country(location["country"]),
location["province"],
# Coordinates.
Coordinates(latitude=coordinates["lat"], longitude=coordinates["long"]),
Expand Down
Loading