From 8ca7351617a4016b75662d985f86ce4f0ea69661 Mon Sep 17 00:00:00 2001 From: Neel Redkar Date: Sat, 14 Mar 2020 14:22:05 -0700 Subject: [PATCH] add object returned --- app/data/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/data/__init__.py b/app/data/__init__.py index c3d5ffa1..2d1cdc1f 100644 --- a/app/data/__init__.py +++ b/app/data/__init__.py @@ -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())) @@ -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. @@ -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',