From 4346c2c28fc1fc029f7848b639b14bde4f781fbe Mon Sep 17 00:00:00 2001 From: IrvinTan <73722805+IrvinTan@users.noreply.github.com> Date: Sat, 24 Jul 2021 22:06:47 -0400 Subject: [PATCH 1/2] Aggregate pattern applied to Location class Modified the location class and added additional classes (Last_updated, Latest) for consistency in references and boundaries. --- app/location/__init__.py | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/app/location/__init__.py b/app/location/__init__.py index 1da5e9e5..e2afbd6b 100644 --- a/app/location/__init__.py +++ b/app/location/__init__.py @@ -11,22 +11,13 @@ class Location: # pylint: disable=too-many-instance-attributes """ def __init__( - self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered, - ): # pylint: disable=too-many-arguments + self, id, country, province, coordinates): # pylint: disable=too-many-arguments # General info. self.id = id self.country = country.strip() self.province = province.strip() self.coordinates = coordinates - # Last update. - self.last_updated = last_updated - - # Statistics. - self.confirmed = confirmed - self.deaths = deaths - self.recovered = recovered - @property def country_code(self): """ @@ -73,6 +64,23 @@ def serialize(self): }, } + def add_last_updated(self): + + def add_latest(self): + +class Last_Updated: + def __init__(last_updated): + self.last_updated = last_updated + + def set_updated(self): + +class Latest: + def __init__(confirmed, deaths, recovered): + self.confirmed = confirmed + self.deaths = deaths + self.recovered = recovered + + def set_latest(self): class TimelinedLocation(Location): """ From d4626735bf9d805fdf21bc5968f200cd64bfcea6 Mon Sep 17 00:00:00 2001 From: IrvinTan <73722805+IrvinTan@users.noreply.github.com> Date: Sat, 24 Jul 2021 22:24:58 -0400 Subject: [PATCH 2/2] Update __init__.py --- app/location/__init__.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/location/__init__.py b/app/location/__init__.py index e2afbd6b..ae9f07e4 100644 --- a/app/location/__init__.py +++ b/app/location/__init__.py @@ -64,10 +64,7 @@ def serialize(self): }, } - def add_last_updated(self): - - def add_latest(self): - + class Last_Updated: def __init__(last_updated): self.last_updated = last_updated