Skip to content

Commit

Permalink
combine actors queries
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Sep 7, 2023
1 parent 1d5f596 commit 74b1acc
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions packages/bsky/src/api/app/bsky/graph/getSuggestedFollowsByActor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,18 @@ export default function (server: Server, ctx: AppContext) {
if (suggestions.length < MAX_RESULTS_LENGTH) {
// backfill with suggested_follow table
const additional = await db.db
.selectFrom('suggested_follow')
.select('did')
.selectFrom('actor')
.innerJoin('suggested_follow', 'actor.did', 'suggested_follow.did')
.where(
'suggested_follow.did',
'actor.did',
'not in',
// exclude any we already have
authorDIDsExcludingActorAndViewer.concat([actorDid, viewer]),
)
.execute()
const additionalActors = await db.db
.selectFrom('actor')
.where(
'actor.did',
'in',
additional.map((a) => a.did),
)
.selectAll()
.execute()

actors.push(...additionalActors)
actors.push(...additional)
}

// this handles blocks/mutes etc
Expand Down

0 comments on commit 74b1acc

Please sign in to comment.