@@ -18,13 +18,15 @@ class JhuLocationService(LocationService):
1818 Service for retrieving locations from Johns Hopkins CSSE (https://github.com/CSSEGISandData/COVID-19).
1919 """
2020
21- def get_all (self ):
21+ async def get_all (self ):
2222 # Get the locations.
23- return get_locations ()
23+ locations = await get_locations ()
24+ return locations
2425
25- def get (self , loc_id ): # pylint: disable=arguments-differ
26+ async def get (self , loc_id ): # pylint: disable=arguments-differ
2627 # Get location at the index equal to provided id.
27- return self .get_all ()[loc_id ]
28+ locations = await self .get_all ()
29+ return locations [loc_id ]
2830
2931
3032# ---------------------------------------------------------------
@@ -103,28 +105,32 @@ async def get_category(category):
103105
104106
105107@cached (cache = TTLCache (maxsize = 1024 , ttl = 3600 ))
106- def get_locations ():
108+ async def get_locations ():
107109 """
108110 Retrieves the locations from the categories. The locations are cached for 1 hour.
109111
110112 :returns: The locations.
111113 :rtype: List[Location]
112114 """
113115 # Get all of the data categories locations.
114- confirmed = get_category ("confirmed" )["locations" ]
115- deaths = get_category ("deaths" )["locations" ]
116- # recovered = get_category('recovered')['locations']
116+ confirmed = await get_category ("confirmed" )
117+ deaths = await get_category ("deaths" )
118+ # recovered = await get_category("recovered")
119+
120+ locations_confirmed = confirmed ["locations" ]
121+ locations_deaths = deaths ["locations" ]
122+ # locations_recovered = recovered["locations"]
117123
118124 # Final locations to return.
119125 locations = []
120126
121127 # Go through locations.
122- for index , location in enumerate (confirmed ):
128+ for index , location in enumerate (locations_confirmed ):
123129 # Get the timelines.
124130 timelines = {
125- "confirmed" : confirmed [index ]["history" ],
126- "deaths" : deaths [index ]["history" ],
127- # 'recovered' : recovered [index]['history'],
131+ "confirmed" : locations_confirmed [index ]["history" ],
132+ "deaths" : locations_deaths [index ]["history" ],
133+ # 'recovered' : locations_recovered [index]['history'],
128134 }
129135
130136 # Grab coordinates.
0 commit comments