@@ -291,6 +291,10 @@ const lookupFromPdcCommand: CommandModule<unknown, LookupFromPdcCommandArgs> = {
291291 apiKey ,
292292 validEins ,
293293 ) ;
294+ if ( ! charityNavResponse . data ) {
295+ logger . warn ( 'No data found' ) ;
296+ return ;
297+ }
294298 if ( args . outputFile ) {
295299 await writeFile (
296300 args . outputFile ,
@@ -299,6 +303,12 @@ const lookupFromPdcCommand: CommandModule<unknown, LookupFromPdcCommandArgs> = {
299303 logger . info ( `Wrote CharityNavigator data for ${ JSON . stringify ( args . ein ) } to ${ JSON . stringify ( args . outputFile ) } ` ) ;
300304 } else {
301305 logger . info ( { charityNavResponse } , 'CharityNavigator result' ) ;
306+ const { edges } = charityNavResponse . data . nonprofitsPublic ;
307+ const nonprofits = edges . filter ( ( e ) : e is NonprofitPublic => isNonprofitPublic ( e ) ) ;
308+ const changemakerIds = nonprofits . map (
309+ ( e ) => getChangemakerByEin ( e . ein , changemakers ) ,
310+ ) . filter ( ( c ) => c !== null ) . map ( ( c ) => c . id ) ;
311+ logger . info ( { changemakerIds } , 'Changemaker IDs present in CharityNavigator' ) ;
302312 }
303313 } ,
304314} ;
@@ -374,7 +384,7 @@ const updateAllCommand: CommandModule<unknown, UpdateAllCommandArgs> = {
374384 // Third, register a batch of changemaker fields to be posted
375385 const fieldBatch = await postChangemakerFieldValueBatch ( args . pdcApiBaseUrl , token , { sourceId : source . id , notes : `data-scripts charityNavigator.ts execution ${ Date . now ( ) } ` } ) ;
376386 // Last, for each nonprofit, for each field, post the field
377- edges . map ( async ( e ) => {
387+ nonprofits . map ( async ( e ) => {
378388 const changemaker = getChangemakerByEin ( e . ein , changemakers ) ;
379389 if ( changemaker !== null ) {
380390 Object . entries ( baseFieldMap ) . map ( async ( [ cnAttributeName , baseFieldShortCode ] ) => {
0 commit comments