Skip to content

Commit 129600f

Browse files
author
ExpDev07
committed
added last_updated to Location
1 parent ab79693 commit 129600f

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

app/location/__init__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ class Location:
66
A location in the world affected by the coronavirus.
77
"""
88

9-
def __init__(self, id, country, province, coordinates, confirmed, deaths, recovered):
9+
def __init__(self, id, country, province, coordinates, last_updated, confirmed, deaths, recovered):
1010
# General info.
1111
self.id = id
1212
self.country = country.strip()
1313
self.province = province.strip()
1414
self.coordinates = coordinates
1515

16+
# Last update.
17+
self.last_updated = last_updated
18+
1619
# Statistics.
1720
self.confirmed = confirmed
1821
self.deaths = deaths
@@ -42,6 +45,9 @@ def serialize(self):
4245
# Coordinates.
4346
'coordinates': self.coordinates.serialize(),
4447

48+
# Last updated.
49+
'last_updated': self.last_updated,
50+
4551
# Latest data (statistics).
4652
'latest': {
4753
'confirmed': self.confirmed,
@@ -55,10 +61,10 @@ class TimelinedLocation(Location):
5561
A location with timelines.
5662
"""
5763

58-
def __init__(self, id, country, province, coordinates, timelines):
64+
def __init__(self, id, country, province, coordinates, last_updated, timelines):
5965
super().__init__(
6066
# General info.
61-
id, country, province, coordinates,
67+
id, country, province, coordinates, last_updated,
6268

6369
# Statistics (retrieve latest from timelines).
6470
confirmed=timelines.get('confirmed').latest or 0,

app/services/location/jhu.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,16 @@ def get_locations():
126126
# Create location (supporting timelines) and append.
127127
locations.append(TimelinedLocation(
128128
# General info.
129-
index, location['country'], location['province'], Coordinates(coordinates['lat'], coordinates['long']),
129+
index, location['country'], location['province'],
130+
131+
# Coordinates.
132+
Coordinates(
133+
coordinates['lat'],
134+
coordinates['long']
135+
),
136+
137+
# Last update.
138+
datetime.utcnow().isoformat() + 'Z',
130139

131140
# Timelines (parse dates as ISO).
132141
{

0 commit comments

Comments
 (0)