diff --git a/app/location/__init__.py b/app/location/__init__.py index 1da5e9e5..e2c92c93 100644 --- a/app/location/__init__.py +++ b/app/location/__init__.py @@ -5,13 +5,22 @@ # pylint: disable=redefined-builtin,invalid-name +class Statistics: + """ + Statistics regarding confirmed, deaths, and recovered cases regarding a location. + """ + def __init__(self, confirmed, deaths, recovered,): + self.confirmed = confirmed + self.deaths = deaths + self.recovered = recovered + class Location: # pylint: disable=too-many-instance-attributes """ A location in the world affected by the coronavirus. """ def __init__( - self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered, + self, id, country, province, coordinates, last_updated, statistics ): # pylint: disable=too-many-arguments # General info. self.id = id @@ -23,9 +32,7 @@ def __init__( self.last_updated = last_updated # Statistics. - self.confirmed = confirmed - self.deaths = deaths - self.recovered = recovered + self.statistics = statistics @property def country_code(self): @@ -67,9 +74,9 @@ def serialize(self): "last_updated": self.last_updated, # Latest data (statistics). "latest": { - "confirmed": self.confirmed, - "deaths": self.deaths, - "recovered": self.recovered, + "confirmed": self.statistics.confirmed, + "deaths": self.statistics.deaths, + "recovered": self.statistics.recovered, }, } diff --git a/app/location/csbs.py b/app/location/csbs.py index 649e8b22..8dd66604 100644 --- a/app/location/csbs.py +++ b/app/location/csbs.py @@ -1,6 +1,6 @@ """app.locations.csbs.py""" from . import Location - +from . import Statistics class CSBSLocation(Location): """ @@ -8,7 +8,7 @@ class CSBSLocation(Location): """ # pylint: disable=too-many-arguments,redefined-builtin - def __init__(self, id, state, county, coordinates, last_updated, confirmed, deaths): + def __init__(self, id, state, county, coordinates, last_updated, statistics): super().__init__( # General info. id, @@ -17,8 +17,8 @@ def __init__(self, id, state, county, coordinates, last_updated, confirmed, deat coordinates, last_updated, # Statistics. - confirmed=confirmed, - deaths=deaths, + confirmed=statistics.confirmed, + deaths=statistics.deaths, recovered=0, )