File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -19,19 +19,21 @@ class Command(BaseCommand):
1919    def  handle (self , * args , ** kwargs ):
2020        logger .info ("Starting NS Inititatives" )
2121        api_key  =  settings .NS_INITIATIVES_API_KEY 
22-         esf_url  =  requests .get (f"https://data-api.ifrc.org/api/esf?apikey={ api_key }  " )
23-         nsia_url  =  requests .get (f"https://data-api.ifrc.org/api/nsia?apikey={ api_key }  " )
24-         cbf_url  =  requests .get (f"https://data-api.ifrc.org/api/cbf?apikey={ api_key }  " )
22+         urls  =  [
23+             f"https://data-api.ifrc.org/api/esf?apikey={ api_key }  " ,
24+             f"https://data-api.ifrc.org/api/nsia?apikey={ api_key }  " ,
25+             f"https://data-api.ifrc.org/api/cbf?apikey={ api_key }  " ,
26+         ]
2527
26-         # resposne for individual request 
27-         esf_response  =  esf_url .json ()
28-         nsia_response  =  nsia_url .json ()
29-         cbf_response  =  cbf_url .json ()
28+         responses  =  []
29+         for  url  in  urls :
30+             response  =  requests .get (url )
31+             if  response .status_code  ==  200 :
32+                 responses .append (response .json ())
3033
3134        added  =  0 
3235
33-         all_fund_data  =  [esf_response , nsia_response , cbf_response ]
34-         flatList  =  [element  for  innerList  in  all_fund_data  for  element  in  innerList ]
36+         flatList  =  [element  for  innerList  in  responses  for  element  in  innerList ]
3537        funding_data  =  pd .DataFrame (
3638            flatList ,
3739            columns = [
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments