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
21 changes: 14 additions & 7 deletions app/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down Expand Up @@ -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,
},
}

Expand Down
8 changes: 4 additions & 4 deletions app/location/csbs.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""app.locations.csbs.py"""
from . import Location

from . import Statistics

class CSBSLocation(Location):
"""
A CSBS (county) 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,
Expand All @@ -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,
)

Expand Down