File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -173,6 +173,7 @@ async function syncUsers(fast42Api: Fast42, lastPullDate: Date | undefined): Pro
173173 log ( 2 , `Processing page ${ pageIndex } with ${ usersData . length } users...` ) ;
174174 const dbUsers = usersData . map ( ( user : any ) => transformApiUserToDb ( user , campusId ) ) ;
175175 await DatabaseService . insertManyUsers ( dbUsers ) ;
176+ // No try-catch block here, needs to fail if users fail to sync, otherwise projectsusers cannot be connected to user ids
176177 }
177178 pageIndex = 0 ;
178179 hasMorePages = true ;
@@ -233,8 +234,13 @@ async function syncProjectUsers(fast42Api: Fast42, lastPullDate: Date | undefine
233234 }
234235
235236 log ( 2 , `Processing page ${ pageIndex } with ${ projectUsersData . length } projectUsers...` ) ;
236- const dbProjectUsers = projectUsersData . map ( transformApiProjectUserToDb ) ;
237- await DatabaseService . insertManyProjectUsers ( dbProjectUsers ) ;
237+ try {
238+ const dbProjectUsers = projectUsersData . map ( transformApiProjectUserToDb ) ;
239+ await DatabaseService . insertManyProjectUsers ( dbProjectUsers ) ;
240+ } catch ( error ) {
241+ console . error ( `Failed to insert project users for project ${ projectId } on page ${ pageIndex } :` , error ) ;
242+ // Continue syncing other project users even if insertion fails, can always repopulate the database
243+ }
238244 }
239245 pageIndex = 0 ;
240246 hasMorePages = true ;
You can’t perform that action at this time.
0 commit comments