Skip to content
Closed
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
9 changes: 6 additions & 3 deletions app/data/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def get_data(category):

# The normalized locations.
locations = []

keys = []
for item in data:
# Filter out all the dates.
dates = dict(filter(lambda element: date_util.is_date(element[0]), item.items()))
Expand All @@ -40,7 +40,10 @@ def get_data(category):

# Latest data insert value.
latest = list(history.values())[-1];

if item['Province/State'] == "":
keys.append(country)
else:
keys.append(item['Province/State'])
# Normalize the item and append to locations.
locations.append({
# General info.
Expand All @@ -66,7 +69,7 @@ def get_data(category):

# Return the final data.
return {
'locations': locations,
'locations': dict(zip(keys, locations)),
'latest': latest,
'last_updated': datetime.utcnow().isoformat() + 'Z',
'source': 'https://github.com/ExpDev07/coronavirus-tracker-api',
Expand Down