diff --git a/src/storages/hydrate.ts b/src/storages/hydrate.ts index 3c264320..00ae59a4 100644 --- a/src/storages/hydrate.ts +++ b/src/storages/hydrate.ts @@ -7,16 +7,19 @@ import { Conf } from '@/config.ts'; import { type DittoEvent } from '@/interfaces/DittoEvent.ts'; import { findQuoteTag } from '@/utils/tags.ts'; import { findQuoteInContent } from '@/utils/note.ts'; +import { Kysely } from 'kysely'; interface HydrateOpts { events: DittoEvent[]; store: NStore; signal?: AbortSignal; + kysely?: Kysely; } /** Hydrate events using the provided storage. */ async function hydrateEvents(opts: HydrateOpts): Promise { - const { events, store, signal } = opts; + const { events, store, signal, kysely = await DittoDB.getInstance() } = opts; + console.log(kysely); if (!events.length) { return events; @@ -57,8 +60,8 @@ async function hydrateEvents(opts: HydrateOpts): Promise { } const stats = { - authors: await gatherAuthorStats(cache), - events: await gatherEventStats(cache), + authors: await gatherAuthorStats(cache, kysely), + events: await gatherEventStats(cache, kysely), }; // Dedupe events. @@ -276,7 +279,10 @@ function gatherReportedProfiles({ events, store, signal }: HydrateOpts): Promise } /** Collect author stats from the events. */ -async function gatherAuthorStats(events: DittoEvent[]): Promise { +async function gatherAuthorStats( + events: DittoEvent[], + kysely: Kysely, +): Promise { const pubkeys = new Set( events .filter((event) => event.kind === 0) @@ -287,8 +293,6 @@ async function gatherAuthorStats(events: DittoEvent[]): Promise { +async function gatherEventStats( + events: DittoEvent[], + kysely: Kysely, +): Promise { const ids = new Set( events .filter((event) => event.kind === 1) @@ -315,8 +322,6 @@ async function gatherEventStats(events: DittoEvent[]): Promise