Skip to content

Commit

Permalink
Trying unexpanded followers
Browse files Browse the repository at this point in the history
  • Loading branch information
allouis committed Aug 7, 2024
1 parent f4ec056 commit a92de86
Showing 1 changed file with 11 additions and 32 deletions.
43 changes: 11 additions & 32 deletions src/dispatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,38 +252,17 @@ export async function followersDispatcher(
handle: string,
) {
console.log('Followers Dispatcher');
let items: Recipient[] = [];
console.time('Followers dispatcher');
console.time('Getting expanded followers');
const fullResults = await ctx.data.db.get<any[]>(['followers', 'expanded']);
console.timeEnd('Getting expanded followers');
if (fullResults) {
console.time(`Creating Objects`);
items = (await Promise.all(
fullResults.map((result, i): Promise<Recipient> => {
return {
...result,
id: new URL(result.id),
inboxId: new URL(result.inbox)
};
})
));
console.timeEnd(`Creating Objects`);
} else {
const results = (await ctx.data.db.get<string[]>(['followers'])) || [];
const actors = items = (await Promise.all(results.map((result) => lookupActor(ctx, result))))
.filter((item): item is Actor => item !== null)
const toStore = await Promise.all(actors.map(actor => actor.toJsonLd() as any));
await ctx.data.db.set(['followers', 'expanded'], toStore);
items = toStore.map((result) => {
return {
...result,
id: new URL(result.id),
inboxId: new URL(result.inbox)
};
});
}
console.timeEnd('Followers dispatcher');
const results = (await ctx.data.db.get<string[]>(['followers'])) || [];
const actors = (await Promise.all(results.map((result) => lookupActor(ctx, result))))
.filter((item): item is Actor => item !== null)
const toStore = await Promise.all(actors.map(actor => actor.toJsonLd() as any));
const items = toStore.map((result) => {
return {
...result,
id: new URL(result.id),
inboxId: new URL(result.inbox)
};
});
return {
items,
};
Expand Down

0 comments on commit a92de86

Please sign in to comment.