this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

initial feature of recrawling profiles

alice 9f37e610 6cb929fc

+31 -4
+31 -4
src/subscription.ts
··· 55 55 .selectFrom('atproto_user') 56 56 .select(['did', 'indexedAt']) 57 57 .where('did', '=', create.author) 58 - // .where('indexedAt', '<=', 'CURRENT_TIMESTAMP - INTERVAL \'1 week\'') 59 58 .execute() 60 59 if (user.length === 0) { 61 60 console.log(`!!!!! fetching profile for ${create.author}`) ··· 107 106 // `${create.author} is ${profile.data.handle} with display name ${profile.data.displayName}`, 108 107 // ) 109 108 } else { 110 - // console.log(new Date(user[0].indexedAt)); 111 - // console.log(user) 112 - // let d = new Date(user[0].indexedAt); 109 + const userDate = new Date(user[0].indexedAt) 110 + const currentDate = new Date() 111 + const oneMonthAgo = new Date(currentDate) 112 + oneMonthAgo.setMonth(currentDate.getMonth() - 1) 113 + if (userDate < oneMonthAgo) { 114 + console.log(`!!!!! recrawling profile for ${create.author}`) 115 + let profile 116 + try { 117 + profile = await agent.api.app.bsky.actor.getProfile({ 118 + actor: create.author, 119 + }) 120 + } catch (e) { 121 + console.error('error fetching profile of recrawled user: ', e) 122 + return 123 + } 113 124 125 + try { 126 + await this.db 127 + .updateTable('atproto_user') 128 + .set({ 129 + did: create.author, 130 + handle: profile.data.handle, 131 + displayName: profile.data.displayName, 132 + bio: profile.data.description, 133 + indexedAt: new Date().toISOString(), 134 + }) 135 + .where('did', '=', create.author) 136 + .execute() 137 + } catch (e) { 138 + console.error('error updating recrawled user: ', e) 139 + } 140 + } 114 141 } 115 142 }) 116 143 }