From 7274f963f0d3d521d1e6533d8ce06db28c42da94 Mon Sep 17 00:00:00 2001 From: Billa32 <87912290+Billa32@users.noreply.github.com> Date: Sun, 25 Jul 2021 23:24:43 -0400 Subject: [PATCH 1/2] Create baseurls.py reason of creating a base_url cause it was assigned hardcoded in scripts and it is better to set hardcoded variables seperately in a class thus created a new baseurl --- app/utils/baseurls.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 app/utils/baseurls.py diff --git a/app/utils/baseurls.py b/app/utils/baseurls.py new file mode 100644 index 00000000..ccebf743 --- /dev/null +++ b/app/utils/baseurls.py @@ -0,0 +1,10 @@ +import enum + +class BaseUrl(str, enum.Enum): + """ + A base url available for retrieving data. + """ + + JHU = "https://raw.githubusercontent.com/CSSEGISandData/2019-nCoV/master/csse_covid_19_data/csse_covid_19_time_series/" + CSBS = "https://facts.csbs.org/covid-19/covid19_county.csv" + NYT = "https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv" From c3d8c6ec538e8d9c75a917e7665aeb39e276a19d Mon Sep 17 00:00:00 2001 From: Billa32 <87912290+Billa32@users.noreply.github.com> Date: Sat, 14 Aug 2021 16:47:17 -0400 Subject: [PATCH 2/2] Creational Pattern Pull Request) Why I did it? I have used the factory design pattern to do my creational pattern where i had to provide an interface for creating objects in superclass, but allowing subclasses to alter the type of objects that will be created. How i did it? I created a new interface class for location to implement creational pattern and the interface for location class is missing so i just added an interface class and serialized the location into a dict. --- app/location/__init__.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/location/__init__.py b/app/location/__init__.py index 1da5e9e5..af29e390 100644 --- a/app/location/__init__.py +++ b/app/location/__init__.py @@ -3,9 +3,18 @@ from ..utils import countries from ..utils.populations import country_population +from abc import abstractmethod, ABCMeta + +class ILocation(metaclass=ABCMeta): + + @abstractmethod + def serialize(): + """ + Serializes the location into a dict. + """ # pylint: disable=redefined-builtin,invalid-name -class Location: # pylint: disable=too-many-instance-attributes +class Location(ILocation): # pylint: disable=too-many-instance-attributes """ A location in the world affected by the coronavirus. """ @@ -74,6 +83,7 @@ def serialize(self): } + class TimelinedLocation(Location): """ A location with timelines.