avsolatorio commited on
Commit
5eb37d7
·
1 Parent(s): 0e20925

Handle case where the data for the country is empty.

Browse files

Signed-off-by: Aivin V. Solatorio <avsolatorio@gmail.com>

Files changed (1) hide show
  1. services.py +8 -0
services.py CHANGED
@@ -202,6 +202,14 @@ def get_wdi_data(
202
  break
203
 
204
  metadata, data_page = json_response
 
 
 
 
 
 
 
 
205
  all_data.extend(data_page)
206
 
207
  if len(all_data) >= MAX_INFO:
 
202
  break
203
 
204
  metadata, data_page = json_response
205
+
206
+ if data_page is None:
207
+ if metadata.get("total") == 0:
208
+ note = "IMPORTANT: Let the user know that the indicator data is not available for the given country and date."
209
+ else:
210
+ note = "ERROR: The API response is invalid or empty."
211
+ break
212
+
213
  all_data.extend(data_page)
214
 
215
  if len(all_data) >= MAX_INFO: