@@ -36,31 +36,40 @@ export const load = async ({ parent }) => {
3636 . filter ( val => val != null ) as Promise < StoredUserInfo > [ ]
3737 ) ;
3838
39- Promise . resolve ( missingUserInfo ) . then ( async allUsers => {
39+ await Promise . resolve ( missingUserInfo ) . then ( async allUsers => {
4040 for ( const user of allUsers ) {
41- console . log ( user . userId , user . provider ) ;
41+ console . log ( "Missing user read" , user . userId , user . provider ) ;
4242
4343 const existingUser = await db . select ( ) . from ( userInfoCache ) . where ( eq ( userInfoCache . userId , user . userId ) ) ;
4444 if ( ! existingUser . length ) {
45- await executeDrizzle (
46- "Insert into user cache" ,
47- db . insert ( userInfoCache ) . values ( {
48- lastSync : + new Date ( ) ,
49- ...user
50- } )
51- ) ;
52- } else {
53- if ( user . provider !== "Legacy" ) {
45+ try {
46+ console . log ( "Inserting user" , user . userId , user . provider ) ;
5447 await executeDrizzle (
55- "Update user cache" ,
56- db
57- . update ( userInfoCache )
58- . set ( {
59- lastSync : + new Date ( ) ,
60- ...user
61- } )
62- . where ( eq ( userInfoCache . userId , user . userId ) )
48+ "Insert into user cache" ,
49+ db . insert ( userInfoCache ) . values ( {
50+ lastSync : + new Date ( ) ,
51+ ...user
52+ } )
6353 ) ;
54+ } catch ( er ) {
55+ console . log ( "Error inserting into user info cache for" , user . userId , er ) ;
56+ }
57+ } else {
58+ if ( user . provider !== "Legacy" ) {
59+ try {
60+ await executeDrizzle (
61+ "Update user cache" ,
62+ db
63+ . update ( userInfoCache )
64+ . set ( {
65+ lastSync : + new Date ( ) ,
66+ ...user
67+ } )
68+ . where ( eq ( userInfoCache . userId , user . userId ) )
69+ ) ;
70+ } catch ( er ) {
71+ console . log ( "Error updating user info cache for" , user . userId , er ) ;
72+ }
6473 }
6574 }
6675 }
0 commit comments