Skip to content

Commit 8ca7351

Browse files
committed
add object returned
1 parent b47847b commit 8ca7351

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

app/data/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def get_data(category):
2727

2828
# The normalized locations.
2929
locations = []
30-
30+
keys = []
3131
for item in data:
3232
# Filter out all the dates.
3333
dates = dict(filter(lambda element: date_util.is_date(element[0]), item.items()))
@@ -40,7 +40,10 @@ def get_data(category):
4040

4141
# Latest data insert value.
4242
latest = list(history.values())[-1];
43-
43+
if item['Province/State'] == "":
44+
keys.append(country)
45+
else:
46+
keys.append(item['Province/State'])
4447
# Normalize the item and append to locations.
4548
locations.append({
4649
# General info.
@@ -66,7 +69,7 @@ def get_data(category):
6669

6770
# Return the final data.
6871
return {
69-
'locations': locations,
72+
'locations': dict(zip(keys, locations)),
7073
'latest': latest,
7174
'last_updated': datetime.utcnow().isoformat() + 'Z',
7275
'source': 'https://github.com/ExpDev07/coronavirus-tracker-api',

0 commit comments

Comments
 (0)